I'm trying to programmatically remove some records off an开发者_如何学Python XML file. But it doesn't seem to work. Here is the code:
foreach ($x->childNodes as $item)
{
if ($item->nodeName == "XMLProduct")
{
echo $item->nodeName . " = " . $item->nodeValue . "<br />";
$item->nodeValue = '';
$item->parentNode->removeChild($item);
$DataCOUNT++;
}
if ($DataCOUNT >10 ) die ('ok for now'); // just trying to stop with 10 rows deleted
}
echo $doc->saveXML();
When I run the code, it doesn't seem to read the line with the last if statement. I wonder what I'm missing...
Really appreciate any input on this.
精彩评论