XML help - adding nodes

Discussion in 'Java' started by Miguel De Anda, Jul 30, 2003.

  1. 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.
     
    Miguel De Anda, Jul 30, 2003
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. asd
    Replies:
    3
    Views:
    461
    Arnaud Berger
    May 23, 2005
  2. gavnosis
    Replies:
    0
    Views:
    548
    gavnosis
    Aug 2, 2003
  3. Timo Nentwig

    selecting nodes between other nodes

    Timo Nentwig, Jun 16, 2004, in forum: XML
    Replies:
    1
    Views:
    437
    Patrick TJ McPhee
    Jun 17, 2004
  4. Johnny Ooi

    Looking A Nodes From Within Nodes

    Johnny Ooi, Nov 13, 2004, in forum: XML
    Replies:
    10
    Views:
    677
    Johnny Ooi
    Nov 14, 2004
  5. th3dude
    Replies:
    0
    Views:
    452
    th3dude
    Jan 3, 2007
Loading...

Share This Page