Reputation: 277
I'm using an old version of the JRE (1.4) where Node.getTextContents() and Node.setTextContents() are not available. Is there a long way to do these actions still?
Example XML:
<MyEle>4119<MyEle/>
Java:
//myEleNode is a Node found while traversing
String nodeString = myEleNode.getTextContent();
if(nodeString.equals("4119")){//do something}
Upvotes: 1
Views: 1754
Reputation: 1150
You will have to iterate over the children, check if their type is text (node.getNodeType() == Node.TEXT_NODE)
and then get the text value using node.getNodeValue()
.
Upvotes: 1
Reputation: 1715
The text is a child node of the MyEle element, so you would use something like:
MyEle.getFirstChild().getNodeValue()
Upvotes: 3