Using getElementsByTagName
I want to access a child node under another node
So I am using this:
NodeList nList = nsoXMLDoc.getElementsByTagName("Details");
It works fine if I specify one node
But if I say :
NodeList nList = nsoXMLDoc.getElementsByTagName("Details/Market");
it gives an error.
How can I specify to go to a sub child node using getElementByName?
Can someone help?
You get the error because "Details/Market" isn't a valid name for an element in XML, and therefore you don't have any such element. You can't put XPath expressions in places that ask you to put in element names.
Probably you want something like this:NodeList nList = nsoXMLDoc.getElementsByTagName("Details");
Node detailsNode = // get a node from that list somehow
NodeList n2List = detailsNode.getElementsByTagName("Market");
Node marketNode = // get a node from that list somehow