How to traverse through all the nodes in an XML document

  • Thread starter Murtaza Tinwala
  • Start date
M

Murtaza Tinwala

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

Sebastian Kerekes

Murtaza said:
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/ .
 

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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top