File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Selecting Node from XML

 
Yogendra Joshi
Ranch Hand
Posts: 213
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Howdy ranchers ,

I am new to XML and would like to know one thing. If i have an xml file in which there are lot of parent nodes with lots of child nodes as well. I would like to print selected nodes from the complete xml file, currently if i give alert, it just covers the part of my screen and shows only that much part of xml which the screen can take. So i would like to know how can i particularly select the Parent node only which i want.

an example to quote is as below :

I have an xml called TxnData.xml which has a lot of other nodes inside it.

now i want to see what data is in other child nodes of TxnData.xml which cant see, How can i do that ?

Please help me.

Thanks and regards,

YogendraJ
 
Thomas Bennett
Greenhorn
Posts: 12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
use XPath.
So if you have

<root>
<parent>
<child1/>
<child2/>
</parent>
<parent>
<child1/>
<child2/>
</parent>
</root>

If you want to see all child2 child nodes then use XPath of '//parent/child2'

If you want to see only the children of the second parent then
'//parent[1]/*'
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic