How to traverse through all the nodes in an XML document

Discussion in 'XML' started by Murtaza Tinwala, Sep 1, 2004.

  1. Hello friends,

    I have a XML document and I want to modify some of its nodes.
    What I need to do is traverse through all the nodes and test the name
    of each. If the node is to be modified, I would output the modified
    code or I would output the same code.

    Is there any way I can get all nodes from the root node? Or, let
    me put this question in another way. Is there an easy way to modify
    XML document. Say, I want to make minor changes to an XML document
    and donot want to touch the rest of the document? How can I do this?

    Murtaza.
    Murtaza Tinwala, Sep 1, 2004
    #1
    1. Advertising

  2. Murtaza Tinwala wrote:

    > Is there any way I can get all nodes from the root node? Or, let
    > me put this question in another way. Is there an easy way to modify
    > XML document. Say, I want to make minor changes to an XML document
    > and donot want to touch the rest of the document? How can I do this?
    >
    > Murtaza.


    You could do your changes using XSLT and use XPath to get the nodes you
    want to edit. An expression like "//*" gets all the nodes in the XML
    document. For a quick introduction to XSLT and XPath have a look at
    http://www.w3schools.com/ .
    Sebastian Kerekes, Sep 1, 2004
    #2
    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. john
    Replies:
    3
    Views:
    6,763
    crawf061
    Jan 30, 2008
  2. gavnosis
    Replies:
    0
    Views:
    492
    gavnosis
    Aug 2, 2003
  3. Replies:
    5
    Views:
    464
    bouton
    Sep 22, 2005
  4. th3dude
    Replies:
    0
    Views:
    419
    th3dude
    Jan 3, 2007
  5. john
    Replies:
    3
    Views:
    109
Loading...

Share This Page