I'm adding nodes to my XML document as part some in-house processing, but cannot get XML::LibXML
to auto-indent the added nodes.
I get output like the following:
Here's what I'm currently getting with $xml->toString( 1 )
:
<nested_nodes>
<nested_node>
<configuration>A</configuration>
<model>45</model>
<added_node>
<ID>
<type>D</type>
<serial>3</serial>
<kVal>3</kVal>
</ID>
</added_node>
</nested_node>
</nested_nodes>
What I would like to have is pretty-printed output:
<nested_nodes>
<nested_node>
<configuration>A</configuration>
<model>45</model>
<added_node>
<ID>
<type>D</type>
<serial>3</serial>
<kVal>3</kVal>
</ID>
</added_node>
</nested_node>
</nested_nodes>
The optional $format
parameter for the toString()
method documented in XML::LibXML::Document
doesn't seem to help.
no_blanks
option to both nested and added nodes. Good work @bvr! – Luzern