我正在尝试使用Xpath选择一个文件。如果Xpath在以下文件中找到匹配的值:
(//Party/PartyIdentification/ID[text()="6655779999"]) OR (//Party/PartyTaxScheme/CompanyID[text()="US6655779999"]和TaxScheme/ID = DEY) OR (//Party/PartyTaxScheme/CompanyID[text()="US6655779999"]和TaxScheme/ID = BSY)
它选择正确的文件。
我开始使用://BuyerParty/Party/PartyIdentification/ID[text()="6655779999"]和它的工作完美!
但是,我不知道如何扩展xpath,以便使用DEY和BSY条件检查其他两条路径。到目前为止,我花了几个星期的时间把论坛翻了个底朝天,想找个答案,但没有运气。
此OR条件的响应是xml文件中可能存在一个、两个或全部三个元素。我不知道是谁先来的。我需要得到上述三个匹配条件的至少一个匹配,以确保选择正确的文件。
对如何解决这个问题有什么想法吗?
<ROOT>
<BuyerParty>
<Party>
<PartyIdentification>
<ID>6655779999</ID>
</PartyIdentification>
<PartyName>
<Name>Charly</Name>
</PartyName>
<Address>
<StreetName>El Cajon Boulevard</StreetName>
<CityName>San Diego</CityName>
<PostalZone>92104</PostalZone>
<Country>
<IdentificationCode>US</IdentificationCode>
</Country>
</Address>
<PartyTaxScheme>
<CompanyID>US11432112341</CompanyID>
<TaxScheme>
<ID>DEY</ID>
</TaxScheme>
</PartyTaxScheme>
<PartyTaxScheme>
<CompanyID>US1143211234</CompanyID>
<TaxScheme>
<ID>BSY</ID>
</TaxScheme>
</PartyTaxScheme>
<Contact>
<Telephone>555-5555555</Telephone>
</Contact>
</Party>
</BuyerParty>
发布于 2014-02-28 10:59:04
您可以使用| (或)选择器
//Party/PartyIdentification/ID[text()="6655779999"]|//Party/PartyTaxScheme/CompanyID[following-sibling::TaxScheme/ID = 'DEY' or following-sibling::TaxScheme/ID = 'BSY'][text()="US11432112341"]https://stackoverflow.com/questions/22092973
复制相似问题