Xml 排除包含具有特定值的子元素的xpath元素
我有以下XML:Xml 排除包含具有特定值的子元素的xpath元素,xml,xpath,Xml,Xpath,我有以下XML: <LowestOfferListings> <LowestOfferListing> <Qualifiers> <ItemCondition>New</ItemCondition> <ItemSubcondition>New</ItemSubcondition> <FulfillmentChannel>Merchan
<LowestOfferListings>
<LowestOfferListing>
<Qualifiers>
<ItemCondition>New</ItemCondition>
<ItemSubcondition>New</ItemSubcondition>
<FulfillmentChannel>Merchant</FulfillmentChannel>
<ShipsDomestically>True</ShipsDomestically>
<ShippingTime>
<Max>0-2 days</Max>
</ShippingTime>
<SellerPositiveFeedbackRating>95-97%</SellerPositiveFeedbackRating>
</Qualifiers>
<NumberOfOfferListingsConsidered>5</NumberOfOfferListingsConsidered>
<SellerFeedbackCount>9197</SellerFeedbackCount>
<Price>
<LandedPrice>
<CurrencyCode>JPY</CurrencyCode>
<Amount>1675.00</Amount>
</LandedPrice>
<ListingPrice>
<CurrencyCode>JPY</CurrencyCode>
<Amount>1275.00</Amount>
</ListingPrice>
<Shipping>
<CurrencyCode>JPY</CurrencyCode>
<Amount>400.00</Amount>
</Shipping>
</Price>
<MultipleOffersAtLowestPrice>False</MultipleOffersAtLowestPrice>
</LowestOfferListing>
<LowestOfferListing>
<Qualifiers>
<ItemCondition>New</ItemCondition>
<ItemSubcondition>New</ItemSubcondition>
<FulfillmentChannel>Merchant</FulfillmentChannel>
<ShipsDomestically>False</ShipsDomestically>
<ShippingTime>
<Max>0-2 days</Max>
</ShippingTime>
<SellerPositiveFeedbackRating>90-94%</SellerPositiveFeedbackRating>
</Qualifiers>
<NumberOfOfferListingsConsidered>3</NumberOfOfferListingsConsidered>
<SellerFeedbackCount>1430</SellerFeedbackCount>
<Price>
<LandedPrice>
<CurrencyCode>JPY</CurrencyCode>
<Amount>1820.00</Amount>
</LandedPrice>
<ListingPrice>
<CurrencyCode>JPY</CurrencyCode>
<Amount>1240.00</Amount>
</ListingPrice>
<Shipping>
<CurrencyCode>JPY</CurrencyCode>
<Amount>580.00</Amount>
</Shipping>
</Price>
<MultipleOffersAtLowestPrice>False</MultipleOffersAtLowestPrice>
</LowestOfferListing>
</LowestOfferListings>
我如何过滤掉那些带有子元素的元素
我试过这些,但不起作用:
count(//*[local-name()='LowestOfferListing']/descendant::*[not(ShipsDomestically='False')])
count(//*[local-name()='LowestOfferListing'][not(ShipsDomestically='False')])
count(//*[local-name()='LowestOfferListing'][not(local-name()='ShipsDomestically'='False')])
这应该行得通
count(//*[local-name()='LowestOfferListing' and descendant::ShipsDomestically = 'False'])
这对名称空间进行了轻微的修改:
count(//*[local-name()='lowstofferlisting'和后代::*[local-name()='shipsdomerically']='True'])
为什么忽略名称空间约束?只需正确处理名称空间。@JLRishe这是MWS响应的一个片段。一些响应对不同的子元素使用多个名称空间,这使得XPath在方法之间的可移植性有点棘手。我发现在很多情况下,在这种情况下忽略名称空间更容易。
count(//*[local-name()='LowestOfferListing' and descendant::ShipsDomestically = 'False'])