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. Advertisements

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. =?Utf-8?B?QXNoYQ==?=

    Adding new XML nodes...

    =?Utf-8?B?QXNoYQ==?=, Aug 10, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    354
    Patrick.O.Ige
    Aug 11, 2005
  2. asd
    Replies:
    3
    Views:
    638
    Arnaud Berger
    May 23, 2005
  3. gavnosis
    Replies:
    0
    Views:
    696
    gavnosis
    Aug 2, 2003
  4. Timo Nentwig

    selecting nodes between other nodes

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

    Looking A Nodes From Within Nodes

    Johnny Ooi, Nov 13, 2004, in forum: XML
    Replies:
    10
    Views:
    915
    Johnny Ooi
    Nov 14, 2004
  6. Replies:
    2
    Views:
    541
  7. th3dude
    Replies:
    0
    Views:
    594
    th3dude
    Jan 3, 2007
  8. cesarcesar
    Replies:
    0
    Views:
    498
    cesarcesar
    Jan 21, 2008
Loading...