Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ C MFC Delphi FoxPro Java Perl PHP Python Ruby SQL Server VBScript
|
Iterate and Delete Iterate over XML child nodes, deleting each child while iterating.
# file: xmlDeleteNodes.pl
use chilkat;
# The Chilkat XML parser is freeware.
# Simple Perl XML example to iterate over child nodes deleting each while
# in progress.
$xml = new chilkat::CkXml();
# Create this XML:
# <?xml version="1.0" encoding="utf-8" ?>
# <colors>
# <color>red</color>
# <color>blue</color>
# <color>green</color>
# <color>yellow</color>
# <color>purple</color>
# <color>orange</color>
# </colors>
# First create the XML:
$xml->put_Tag("colors");
$xml->NewChild2("color","red");
$xml->NewChild2("color","blue");
$xml->NewChild2("color","green");
$xml->NewChild2("color","yellow");
$xml->NewChild2("color","purple");
$xml->NewChild2("color","orange");
$xml->SaveXml("output/colors.xml");
# Load the XML and iterate/delete:
$xml2 = new chilkat::CkXml();
$xml2->LoadXmlFile("output/colors.xml");
while ($xml2->get_NumChildren() > 0)
{
$child = $xml2->GetChild(0);
print $child->content . "\n";
$child->RemoveFromTree();
}
|
Need a specific example? Send a request to support@chilkatsoft.com
© 2000-2007 Chilkat Software, Inc. All Rights Reserved.