This is regarding the XML parsing .I am using xerces parser for parsing the xml.I am trying to get the node value null when i invoke the method getNodeValue()....
assuem this is my xml
I need to get the TestingXML ....Can anyone explian me how to get...
Thanking advance for ur valuable reply...
After u reach a node u can get the name by calling the method getNodeName(),but to get the node value u have to do a getFirstChild() and then do getNodeValue(),this is because the node value is one level below the node name
Hi is working thanks,
Let me know where i can get some sames on these ...
I would like to know how to get the childes
< FirstXML> FirstXML Test
I would thank u for the above information...
NodeList nl = doc.getElementsByName("Testxml");
Node n = nl.getFirstChild(); // I think, been a while!
String t = n.getNodeValue();
t should now contain the value you want.
Bear in mind, that getFirstChild() will return the FIRST CHILD. If you add an attribute to the tag, such as
then getFirstChild() will probably return the attribute now, rather than the node value itself, which now becomes the LAST child of the node.
PS. I have been forced to use the MSXML Dom recently, in which the above is most definitely true, and to the best of my knowledge it's true for all of them. Also, in a moment of sheer adequacy the MSXML Dom is amazing quick! Shocked the hell out of me! :-)
Missed out a piece.
Node n = nl.children(0).getFirstChild();
Note the added children(0). Might have the name of the method wrong, but you can work it out! :-)