7

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?

2 Answers 2

7

Try this:

parent.getElementsByTagName('Url')[0].childNodes[0].nodeValue
Sign up to request clarification or add additional context in comments.

Comments

0

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.

1 Comment

@user1767754 I think your browser is kaputt, because the link is perfectly fine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.