I am studying usage XML:LibXMLfor a project in Perl, and I saw this example .
The goal is to create this XML file:
<?xml version="1.0" encoding="utf-8"?>
<assets xmlns="http://bricolage.sourceforge.net/assets.xsd">
<story id="1234" type="story">
<name>Catch as Catch Can</name>
</story>
</assets>
The author uses addChildto create storyunder assets:
my $story = $dom->createElement('story');
and then also uses addChild(in conjunction with createAttribute) to specify attributes for story:
$story->addChild( $dom->createAttribute( id => 1234));
Looking at the XML example above (without knowing about XML) is id="1234"not a child story , but rather an attribute, so why do we use addChild in this last line?
source
share