Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
给定以下 XML
<Address> <CountryName>France</CountryName> </Address> ... <Address> <CountryName>Germany</CountryName> </Address> ... <Address> <CountryName>Spain</CountryName> </Address>
如何使用 XPath 1.0 计算不同国家的数量?
地址列表很长,包含许多不同的国家,所以我想避免具体表达每个国家。
选择值与当前元素的父元素的以下兄弟元素的子元素CountryName不同的值的所有元素的计数:CountryNameCountryNameAddress
CountryName
Address
count(//Address/CountryName[not(.=../following-sibling::Address/CountryName)])