Xpath缺少某些节点

时间:2019-01-11 17:27:07

标签: php xml xpath woocommerce nodes

我有XML库存表文件。节点就像这样:`

<StockID>26868</StockID>

<LatinName>'The Garland' AGM</LatinName>

<CommonName>Rose</CommonName>

<DetailedDescription>A vigorous spreading climber. Masses of small semi-double creamy-white tinted pink daisy like flws. Very fragrant. Ht 15ft x 10ft. Lovely growing through trees or shrubs. Shade tolerant. Very hardy.</DetailedDescription>

<SalePriceIncVAT>19.99</SalePriceIncVAT>

<VATValue>20</VATValue>

<SalePrice>16.6583</SalePrice>

<QuantityAvailable>3</QuantityAvailable>

<GroupDescription>Roses</GroupDescription>


<GenusDescription>Rosa</GenusDescription>

<PotSize>4</PotSize>

<Locations>

  <Location>

    <Description>Nursery</Description>

    <Quantity>3</Quantity>

  </Location>

</Locations>

<Classifications>

  <Classification>

    <Description>Soil Type</Description>

    <Value>Any reasonable soil</Value>

  </Classification>

</Classifications>

`

我正在使用PHP处理文件

    $_product = wc_get_product($id);

if($_product){ // check if it's got a product

$sku = $_product->get_sku();

$nodes = $xml->xpath('//StockDetails/StockDetail/StockID[.="'.$sku.'"]/parent::*');         
$result = $nodes[0];



    if(isset($result)){ 

它工作得很好,但是很遗憾,它是一个很大的文件。它包含约8000个节点。

问题是-由于某种原因,它缺少约200个节点。

我认为我的Xpath行是错误的。

有人可以引导我寻求解决方案吗?

0 个答案:

没有答案