For the message below, my parsing code is giving :name #text value.
Why it is returing this record?
Message:
<emp>
<emp_name>david</emp-name>
<emp-no>123</emp-no>
</emp>
code:
final Document doc = parser.loadXml(message);
doc.getDocumentElement().normalize();
NodeList nodeList = doc.getDocumentElement().getChildNodes();
public Map<String, String> getElementKeyValue(NodeList nodeList) {
Map<String, String> elements = new HashMap<String, String>();
if (nodeList != null && nodeList.getLength() > 0) {
for (int i = 0; i < nodeList.getLength(); i++) {
Node node = nodeList.item(i); // Take the node from the list
NodeList valueNode = node.getChildNodes(); // get the children // of the node
String value = (valueNode.item(0) != null) ? valueNode.item(0)
.getNodeValue() : "";
System.out.println("name " + node.getNodeName() + " value "
+ value);
elements.put(node.getNodeName(), value);
}
}
return elements;
}