|
I must be getting stupid as the night wears on...
can someone point me in the direction in what error I am making?
For the following XML document:
<?xml version="1.0"?>
<JavaXML:xmlrpc-config
xmlns:JavaXML="http://myUrl.com">
<JavaXML:hostname>localhost</JavaXML:hostname>
<JavaXML:port
type="unprotected">85</JavaXML:port>
</JavaXML:xmlrpc-config>
and this code snippet:
try {
DOMParser parser = new
(org.apache.xerces.parsers.)DOMParser();
parser.parse(uri); // Parse supplied document
Document doc =
parser.getDocument();
NodeList nodes =
doc.getElementsByTagName("JavaXML:hostname");
if (nodes.getLength() > 0)
{
hostname =
nodes.item(0).getNodeValue();
}
nodes =
doc.getElementsByTagName("JavaXML:port");
if (nodes.getLength() > 0)
{
portNumber =
(Integer.parseInt(nodes.item(0).getNodeValue());
}
} // exception handling
this never pulls any data out for me. However,
NodeList nodes = doc.getElementsByTagName("*");
and then printing each node's getNodeName() result gives me:
JavaXML:xmlrpc-config
JavaXML:hostname
JavaXML:port
What am I missing?
Thanks,
Brett |
- Re: Late night DOM question Brett McLaughlin
- Re: Late night DOM question Chris Gokey
