This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes reading xml document by parsing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "reading xml document by parsing" Watch "reading xml document by parsing" New topic

reading xml document by parsing

kamesh aru
Ranch Hand

Joined: Mar 16, 2002
Posts: 150
in my xml file i got

howto get peter ?

i am using xerces parser

fallowing code giving "name" as out put
Document doc = parser.getDocument();
NodeList nodes = doc.getElementsByTagName("name");
System.out.println("There are " + nodes.getLength() +" elements.");

for(int i=0 ; i <nodes.getLength() ;i++){
Node nodename = nodes.item(i);
System.out.println("node name"+nodename.getLocalName() );

thanks in advance
K Riaz
Ranch Hand

Joined: Jan 08, 2005
Posts: 375

Assuming you have just that element in your whole XML.
kamesh aru
Ranch Hand

Joined: Mar 16, 2002
Posts: 150
i am having list of names ,i need to capture so i am using the for loop
need a better solution
thanks for the responce
It is sorta covered in the JavaRanch Style Guide.
subject: reading xml document by parsing
It's not a secret anymore!