开发者

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

开发者 https://www.devze.com 2023-03-28 04:42 出处:网络
I\'m trying to programmatically remove some records off an开发者_如何学Python XML file. But it doesn\'t seem to work. Here is the code:

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

精彩评论

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