Android

getting attributes with DOM & xpath

aucd29 2013. 10. 8. 14:53
[code]
NodeList nodes = (NodeList)evaluate(feature + "[@required='true']", XPathConstants.NODESET);
            
for (int i=0; i<nodes.getLength(); ++i) {
    NamedNodeMap attributes = nodes.item(i).getAttributes();

    for (int j=0; j<attributes.getLength(); ++j) {
        Log.d(TAG, attributes.item(j).getNodeName() + " : " + attributes.item(j).getNodeValue());
    }
}
[/code]