【发布时间】:2017-07-22 12:23:31
【问题描述】:
我想从此 xml 中删除子标签。例如我想删除这个
"<ExtraCategory diffgr:id="ExtraCategory1" msdata:rowOrder="0">
<Barcode>5051694676090</Barcode>
<CategoryID>1</CategoryID>
<Value>High Quality</Value>
</ExtraCategory>"
孩子。我就是这样解析xml的。
$doc = new DOMDocument();
$doc->loadXML($Xmlresult);
$xpath = new DOMXpath($doc);
unset($doc->xpath("ExtraCategory[@diffgr:id=$id]")[0]);
但未能删除。我已经在stackoverflow上完成了所有的anwsers,但未能得到解决方案。任何帮助将不胜感激。我的 xml 如下:
<DocumentElement
xmlns="">
<ExtraCategory diffgr:id="ExtraCategory1" msdata:rowOrder="0">
<Barcode>5051694676090</Barcode>
<CategoryID>1</CategoryID>
<Value>High Quality</Value>
</ExtraCategory>
<ExtraCategory diffgr:id="ExtraCategory2" msdata:rowOrder="1">
<Barcode>5051694676090</Barcode>
<CategoryID>2</CategoryID>
<Value>Stylish Appearance</Value>
</ExtraCategory>
<ExtraCategory diffgr:id="ExtraCategory3" msdata:rowOrder="2">
<Barcode>5051694676090</Barcode>
<CategoryID>3</CategoryID>
<Value>In Fashion</Value>
</ExtraCategory>
【问题讨论】:
标签: php xml xml-parsing