This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan 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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "reading xml document by parsing" Watch "reading xml document by parsing" New topic
Author

reading xml document by parsing

kamesh aru
Ranch Hand

Joined: Mar 16, 2002
Posts: 150
in my xml file i got
<name>peter</name>

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
 
Similar Threads
XPath expression constrained by a predicate doesn't work (//element[@attribute="value"])
simple JAXPquestion
help!Urgent,my assignment.....
a ReadXMLFile Servlet works without my expectation...
XML Parsing