开发者

Trouble deleting a record/node from and XML file in PHP

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜