Reputation: 5511
According to this page, I think I have done this right... or at least so I think.
I want to parse this:
<Title>Bananas</Title>
Here is some code.
node1.getNodeName(); // returns "Title" *correct*
node2 = node1.getNextSibling();
node2.getNodeName(); // returns "#text" *correct*
node2.getNodeType() == Node.TEXT_NODE // returns true *correct*
node2.getNodeValue(); // returns "" *should return "Bananas"*
According to the documentation, shouldn't the call to getNodeValue() on a Text Node return its text value?
Upvotes: 1
Views: 675
Reputation: 14331
You're accessing the text after the </title>
You probably want something like node1.getFirstChild()
Use this line instead
node2 = node1.getFirstChild();
Upvotes: 1