XML help - adding nodes

M

Miguel De Anda

I've made a little tool that I use to read and use xml files. I've made a
method that would return a desired node from the dom, and if it isn't found,
it will add it. So for example if I have the tree:


<a>
<b id="0">
<c>value of c</c>
</b>
</a>

and I call getNode("a.b.c") then it returns the node "c" which has the value
of "value of c" in it. I'm trying to extend that a bit and also allow it to
get attributes (I hope I'm even calling them right, but the id="0" part in
the example above).

I haven't tested the reading part yet but I was trying to add it using the
code:

Node abc = ...
Node id = document.createAttribute("id");
abc.appendChild(id);

and I get a "HEIRARCY_REQUEST_ERR: An attempt was made to insert a node
where it is not permitted". How am I supposed to do this? Thanks in advance.

Miguel.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top