我要求提取低于值。
<cidx:ReferenceInformation ReferenceType="DeliveryNoteNumber">
<cidx:DocumentReference>
<cidx:DocumentIdentifier>5004330471</cidx:DocumentIdentifier>
</cidx:DocumentReference>
</cidx:ReferenceInformation>
我使用下面的Xpath表达式并获得2个值匹配。
表达式
/*[local-name()='Envelope']/*[local-name()='Body']/*[local-name()='ShipNotice']/*[local-name()='ShipNoticeBody']/*[local-name()='ShipNoticeProperties']/*[local-name()='ReferenceInformation']/*[local-name()='DocumentReference']/*[local-name()='DocumentIdentifier']/text()
输出
<?xml version="1.0" encoding="UTF-8"?>
<result>
5004330471
0803692106
</result>
我在在线工具中测试了Xpath [http://www.xpathtester.com/xpath][1]
以下是 INPUT XML
<SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP:Header/>
<SOAP:Body>
<cidx:ShipNotice xmlns:cidx="urn:cidx:names:specification:ces:schema:all:4:0" Version="4.0">
<cidx:Header>
<cidx:ThisDocumentIdentifier>
<cidx:DocumentIdentifier>0000001113658104</cidx:DocumentIdentifier>
</cidx:ThisDocumentIdentifier>
<cidx:ThisDocumentDateTime>
<cidx:DateTime DateTimeQualifier="On">2015-01-22T20:15:35Z</cidx:DateTime>
</cidx:ThisDocumentDateTime>
<cidx:From>
<cidx:PartnerInformation>
<cidx:PartnerName>MOS Company</cidx:PartnerName>
<cidx:PartnerIdentifier Agency="AGIIS-EBID">1234567890123</cidx:PartnerIdentifier>
<cidx:AddressInformation>
<cidx:AddressLine>N. Lindbergh</cidx:AddressLine>
<cidx:CityName>Columbia</cidx:CityName>
<cidx:StateOrProvince>MO</cidx:StateOrProvince>
<cidx:PostalCode>63190</cidx:PostalCode>
<cidx:PostalCountry>US</cidx:PostalCountry>
</cidx:AddressInformation>
</cidx:PartnerInformation>
</cidx:From>
<cidx:To>
<cidx:PartnerInformation>
<cidx:PartnerName> DIV BOWLNG GR VERA</cidx:PartnerName>
<cidx:PartnerIdentifier Agency="AssignedByPapiNet">0001664057</cidx:PartnerIdentifier>
<cidx:ContactInformation>
<cidx:ContactName>2015</cidx:ContactName>
<cidx:ContactDescription>SeedYear</cidx:ContactDescription>
</cidx:ContactInformation>
<cidx:ContactInformation>
<cidx:ContactName>1024122440000</cidx:ContactName>
<cidx:ContactDescription>AGIIS-EBID</cidx:ContactDescription>
</cidx:ContactInformation>
<cidx:AddressInformation>
<cidx:AddressLine>17410 PIKE 291</cidx:AddressLine>
<cidx:CityName>BOWLING GREEN</cidx:CityName>
<cidx:StateOrProvince>MO</cidx:StateOrProvince>
<cidx:PostalCode>633343045</cidx:PostalCode>
<cidx:PostalCountry>US</cidx:PostalCountry>
</cidx:AddressInformation>
</cidx:PartnerInformation>
</cidx:To>
</cidx:Header>
<cidx:ShipNoticeBody>
<cidx:ShipNoticeProperties>
<cidx:ShipmentIdentification>
<cidx:DocumentReference>
<cidx:DocumentIdentifier>0803692106</cidx:DocumentIdentifier>
</cidx:DocumentReference>
</cidx:ShipmentIdentification>
<cidx:ShipDate>
<cidx:DateTime DateTimeQualifier="On">2015-01-22T00:00:00Z</cidx:DateTime>
</cidx:ShipDate>
<cidx:PurchaseOrderInformation>
<cidx:DocumentReference>
<cidx:DocumentIdentifier>PO8956234</cidx:DocumentIdentifier>
<cidx:ReferenceItem>000530</cidx:ReferenceItem>
</cidx:DocumentReference>
</cidx:PurchaseOrderInformation>
<cidx:TransportMethodCode Domain="UN-Rec-19">3</cidx:TransportMethodCode>
<cidx:ReferenceInformation ReferenceType="DeliveryNoteNumber">
<cidx:DocumentReference>
<cidx:DocumentIdentifier>5004330471</cidx:DocumentIdentifier>
</cidx:DocumentReference>
</cidx:ReferenceInformation>
<cidx:ReferenceInformation ReferenceType="BillOfLadingNumber">
<cidx:DocumentReference>
<cidx:DocumentIdentifier>0803692106</cidx:DocumentIdentifier>
</cidx:DocumentReference>
</cidx:ReferenceInformation>
<cidx:ShipNoticeDate>
<cidx:DateTime DateTimeQualifier="On">2015-01-22T20:15:35Z</cidx:DateTime>
</cidx:ShipNoticeDate>
</cidx:ShipNoticeProperties>
</cidx:ShipNoticeBody>
</cidx:ShipNotice>
</SOAP:Body>
</SOAP:Envelope>
任何人都可以建议如何获得这个价值吗?
<cidx:DocumentIdentifier>5004330471</cidx:DocumentIdentifier>
答案 0 :(得分:0)
您似乎需要测试ReferenceType
元素中的cidx:ReferenceInformation
属性:
/*[local-name()='Envelope']/*[local-name()='Body']/*[local-name()='ShipNotice']/*[local-name()='ShipNoticeBody']/*[local-name()='ShipNoticeProperties']/*[local-name()='ReferenceInformation' and @ReferenceType='DeliveryNoteNumber']/*[local-name()='DocumentReference']/*[local-name()='DocumentIdentifier']
注意:如果您可以声明命名空间并在路径中使用前缀,则可以清除此xpath。
如果您使用的是XPath 2.0,也可以使用*
清除前缀...
/*:Envelope/*:Body/*:ShipNotice/*:ShipNoticeBody/*:ShipNoticeProperties/*:ReferenceInformation[@ReferenceType='DeliveryNoteNumber']/*:DocumentReference/*:DocumentIdentifier