0
排除XPath的元素我有以下XML:有孩子具有一定价值
<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>
我试图让有ShipsDomestically='False'
而忽略任何命名空间的限制所有LowestOfferListing
元素的计数。
这将让我所有房源的计数:
count(//*[local-name()='LowestOfferListing'])
我怎么会过滤掉那些有子元素?
我尝试了这些,但他们不工作:
count(//*[local-name()='LowestOfferListing']/descendant::*[not(ShipsDomestically='False')])
count(//*[local-name()='LowestOfferListing'][not(ShipsDomestically='False')])
count(//*[local-name()='LowestOfferListing'][not(local-name()='ShipsDomestically'='False')])
你为什么忽略的命名空间的限制?只需正确处理命名空间。 – JLRishe 2014-09-24 09:27:09
@JLRishe这是来自MWS响应的片段。某些响应对不同的子元素使用多个名称空间,这可能会使方法之间的Xpaths的可移植性有点棘手。在很多情况下,我发现在这种情况下忽略名称空间会更容易。 – eComEvo 2014-09-24 13:32:54