I am trying to values of specific Nodes from an xml file, this is working fine.
However, there is one line i can’t read which is :
<misc viewers="898" duration="6684"/>
I can find the node, but getNodeValue() and getTextContext() both return null.
Is there a workaround to get the contents of this line?
Thanks
edit : i am using this loop to find nodes
NodeList nodes = doc.getElementsByTagName("item");
for (int i = 0; i < nodes.getLength(); i++) {
Element element = (Element) nodes.item(i);
System.out.println("Title: "
+ getElementValue(element, "title"));
System.out
.println("embed: " + getElementValue(element, "misc"));
System.out.println();
}
viewersanddurationare attributes of themiscnode, not values. You need to callgetAttributes()to get a NamedNodeMap of all the attributes, then callgetNamedItem()on your node map to access a specific attribute.