Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

reading xml document by parsing

 
kamesh aru
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 375
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Assuming you have just that element in your whole XML.
 
kamesh aru
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic