1
我想打印出下面的代码属性值的值:如何打印在JSP/DOM属性
ArrayList arrayList=new ArrayList();
String = "tagToFind";
Node n = node.getParentNode();
String printOut = "";
while (n != null && !n.getNodeName().equals(tagToFind)) {
n = n.getParentNode();
}
if (n != null){
arrayList.add(n.getNodeValue());
out.println(n.getAttribute("attributeName");
}
但在通过out.println(n.getAttribute(“的attributeName “);我得到一个”方法getAttribute(字符串)未定义的类型节点“错误我假设因为n是一个节点,而不是一个节点列表。是否有替代我可以使用?或解决此问题的一种方法?