1
XML节点我想根据属性值
<!-- url path="/jsp/Admin_BetaSignup.jsp" roles="ZohoCampaignAdmin" authentication="optional" description="Page used to add the Beta users">
<param name="zuid" xss="throwerror" max-len="300"/>
</url -->
我要选择通过XPath的这个节点选择一个注释节点。我在java中使用下面的代码。
Document document = DocumentBuilderFactory.newInstance()
.newDocumentBuilder()
.parse("/home/local/ZOHOCORP/bharathi-1397/build/AdventNet/Sas/webapps/zcadmin/WEB-INF/security.xml");
XPath xpath = XPathFactory.newInstance().newXPath();
System.out.println(
xpath.evaluate("//comment()[@path='/jsp/Admin_BetaSignup.jsp']",
document,XPathConstants.NODE)
);
输出:null。
为什么?
我不认为意见可以有属性... – beerbajay