java获得smil文件节点的属性值

/**
* 获得smil文件节点的属性值<br>
*
* @param name
* @param attrName
* @return
*/
public String getAttr(String name, String attrName) {
System.out.println("###======= getAttr() start ===========");
String result = "";
List valuesList = new ArrayList();
ArrayList<?> resultlist = findNodes(name);
System.out.println("###resultlist:" + resultlist.size());
if ((resultlist != null) && (resultlist.size() > 0)) {
for (int i = 0; i < resultlist.size(); i++) {
Node node = (Node) resultlist.get(i);
if (node instanceof Element) {

if ((node != null) && (node.getNodeName() != null)) {
// 遍历整个smil某节点指定的属性
NamedNodeMap attrs = node.getAttributes();
if (attrs.getLength() > 0 && attrs != null) {
Node attr = attrs.getNamedItem(attrName);
result = attr.getNodeValue();

// System.out.println("###result:" + result);
}

}
}

System.out.println("###getAttr()-->result:" + result);

// valuesList.add(result);
}
}
return result;
}

你可能感兴趣的:(java)