Here you can find the source of getTagAttributeRecursive(String sTag, String sAtt, Element eElement)
Parameter | Description |
---|---|
sTag | Tag name |
sAtt | Attribute name |
eElement | The XML node |
public static String getTagAttributeRecursive(String sTag, String sAtt, Element eElement)
//package com.java2s; //License from project: Open Source License import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { /**//from www.ja va2 s.c o m * XML helper to retrieve an attribute of a node * @param sTag Tag name * @param sAtt Attribute name * @param eElement The XML node * @return Attribute value */ public static String getTagAttributeRecursive(String sTag, String sAtt, Element eElement) { NodeList nList = eElement.getElementsByTagName(sTag); if (nList == null) return null; Node node = nList.item(0); if (node == null) return null; Node attNode = node.getAttributes().getNamedItem(sAtt); if (attNode == null) return null; return attNode.getNodeValue().toString(); } }