http://qs321.pair.com?node_id=830411

itsscott has asked for the wisdom of the Perl Monks concerning the following question:

Good day Monks!

I have a config xml file that I actually created with the xml lib so I know it's valid ;-) It is nicely formatted with nice indents etc as toString(1) does so well.
I wanted to add an entry to it so I parsed it in, added to it and saved it again with toString(1)... Oddly the elements we all on one line and not pretty like the rest of the document. Here is a brief example.
my ($configuri) = $basepath."config.xml"; my $cparser = XML::LibXML->new(); # load config file my $config = $cparser->parse_file($configuri); # then an xpath to get to where I want to be foreach my $xsites ($lrconfig->findnodes("//linkrabbitconfig/sites")) { $xnewsite = $config->createElement('site'); $xsites->appendChild($xnewsite); $xsitename = $config->createElement('sitename'); $xnewsite->addChild($xsitename); $xsitename->addChild( $config->createCDATASection($args{'site'}) ) +; # add a bunch more elements } # output xml file open (XMLfile,">".$configuri); binmode(XMLfile,":utf8"); autoflush XMLfile 1; chmod 0664, $outfile; # dump the xml document to file print XMLfile $config->toString(1); close(XMLfile);
Any help would be very much appreciated, I am thinking that it might have a something to do with a xml object and a dom object? Am I close?

Thank you in advance!
Scott