I'm sorry, I wanna ask about how to get tag value with considering tag name and its attribute. I use the XML for indexing on lucene
This is the XML
<?xml version="1.0" encoding="utf-8"?>
<Root xmlns:wb="http://www.worldbank.org">
<data>
<record>
<field name="Country or Area" key="ARB">Arab World</field>
<field name="Item" key="AG.AGR.TRAC.NO">Agricultural machinery, tractors</field>
<field name="Year">1961</field>
<field name="Value">73480</field>
</record>
</data>
</Root>
In early project, I only get the tag value with source like this:
private String getTagValue(String tag, Element e) {
NodeList nlList = e.getElementsByTagName(tag).item(0).getChildNodes();
Node nValue = (Node) nlList.item(0);
return nValue.getNodeValue();
}
But now, I want considering its attribute, so I must define what tag and the attribute to get the correct value. Thanks for the answer