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?

[456 byte] By [bhuru_luthriaa] at [2007-11-27 6:52:17]
# 1

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

DrClapa at 2007-7-12 18:26:45 > top of Java-index,Java Essentials,Java Programming...