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