views:

270

answers:

2

I have a line that gets the nodeValue of a Node:

parent.getElementsByTagName("Url")[0].nodeValue

that returns nothing:

<br/>

When I do:

parent.getElementsByTagName("Url")[0].toxml()

it returns:

< Url>www.something.com< /Url>

I am not sure what is going on here. Another data point: when I do nodeName instead of nodeValue it returns, as expected, Url.

Any thoughts?

A: 

The DOM Level 2 documentation states that nodeName for an element node is the tag name, the nodeValue is always null and attributes is a NamedNodeMap, so this code behaves as expected.

Torsten Marek
+1  A: 

Try this:

parent.getElementsByTagName('Url')[0].childNodes[0].nodeValue
Attila Oláh