21,893
社区成员




$strXML = <<<TEST
<?xml version="1.0"?>
<test>
<Transaction>
<Item>
<ItemID>280274064551</ItemID>
</Item>
<orderid>555</orderid>
<listid>300</listid>
</Transaction>
<Transaction>
<Item>
<ItemID>280274064551</ItemID>
</Item>
<orderid>555</orderid>
<listid>290</listid>
</Transaction>
</test>
TEST;
$doc = new DOMDocument;
$doc->loadXML($strXML);
$trans = $doc->documentElement->getElementsByTagName('Transaction');
$length = $trans->length;
for($i=0;$i< $length; $i++)
{
$listid = $trans->item($i)->getElementsByTagName('listid');
$tmpid = $listid->item(0)->nodeValue;
if($tmpid == 300)
{
$trans->item($i)->parentNode->removeChild($trans->item($i));
//$listid->parentNode->parentNode->removeChild($listid->parentNode);
break;
}
}
echo $doc->saveXML();