用XPath.selectSingleNode(root,xpath)方法来查询具体某个节点。
根据单个属性查询:
Element findelement=(Element)XPath.selectSingleNode(root,"/root/biaodan[@bdname='"+chkname+"']");
根据多个属性查询:
Element findelement=(Element)XPath.selectSingleNode(root,"/root/biaodan[@bdname='"+chkname+"'][@liuname='"+flowname+"']");
根据多个属性查询,(多属性之间或的关系):
Element findelement=(Element)XPath.selectSingleNode(root,"/root/biaodan[@bdname='"+chkname+"'] | /root/biaodan[@liuname='"+flowname+"']");
根据单个属性查询:
Element findelement=(Element)XPath.selectSingleNode(root,"/root/biaodan[@bdname='"+chkname+"']");
根据多个属性查询:
Element findelement=(Element)XPath.selectSingleNode(root,"/root/biaodan[@bdname='"+chkname+"'][@liuname='"+flowname+"']");
根据多个属性查询,(多属性之间或的关系):
Element findelement=(Element)XPath.selectSingleNode(root,"/root/biaodan[@bdname='"+chkname+"'] | /root/biaodan[@liuname='"+flowname+"']");
本文介绍了如何使用XPath.selectSingleNode方法根据单个或多个属性查询XML文档中的特定节点。包括精确匹配及属性间或关系的复杂查询。
437

被折叠的 条评论
为什么被折叠?



