Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Hello Monks,
I'm fairly new to Perl and started recently to learn Perl to parse and work with XML files. Pretty neat and easy.
I'm currently using ::LibXML and having formatting problem. I am adding new node to an existing node using
worked fine but the formatting of each file is different for example my output would look something like:
<root_tag> <element1>text</element1> #space <element2>text</element2> #space <element3>txt</element3> <new_node> <new_element1>text</new_element1> <new_element2>text</new_element2><new_element3> </new_element3> </new_node> </root_tag>
in the above example my existing XML file has spaces between elements, where my new source file doesn't i.e <new_node>.
also the tags gets missed up when copied i.e <new_element2>text</new_element2><new_element3>
indentation is also not precise. Im outputting my results to a file using
$new_object->toString(2;);
$new_object->toFile('file_name.xml');
so in summary the question is whats the best way when using LibXML to get a nice formatted XML output.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: XML output formatting
by Discipulus (Canon) on Dec 10, 2013 at 08:48 UTC | |
|
Re: XML output formatting (XML::LibXML::PrettyPrint)
by Anonymous Monk on Dec 10, 2013 at 06:28 UTC | |
by Preceptor (Deacon) on Dec 10, 2013 at 22:13 UTC | |
by Anonymous Monk on Dec 10, 2013 at 22:47 UTC | |
|
Re: XML output formatting
by locked_user sundialsvc4 (Abbot) on Dec 10, 2013 at 15:53 UTC | |
|
Re: XML output formatting
by roboticus (Chancellor) on Dec 10, 2013 at 22:47 UTC |