Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Mirod, I'm testing with XML::Twig v3.15 on WinXP and v3.16 on Linux, both produce the same behavior.

Here is a minimal test stub that re-creates the formatting issue on my test machines.

#!/bin/perl -w use strict; use XML::Twig; my $file = 'input.xml'; my $parser = new XML::Twig(KeepSpaces => 'true', ErrorContext => 2); $parser->parsefile($file); my $sc = $parser->root->first_child( q{ServerCluster[@Name="cl_app302_ +prod"]} ); my $ps = $sc->first_child('PrimaryServers'); $ps->cut_children; $ps->insert_new_elt( Server => { Name => "New_1"}); $ps->insert_new_elt( Server => { Name => "New_2"}); open(PF, "> out.xml") or die "can't open file $!\n"; $parser->root->print(\*PF);
The input.xml file contains:
<?xml version="1.0" encoding="ISO-8859-1"?> <Config ASDisableNagle="false" AcceptAllContent="false" IISDisableNagl +e="false" IgnoreDNSFailures="false" RefreshInterval="60" ResponseChun +kSize="64"> <Log LogLevel="Error" Name="/opt/IBMWebAS/logs/native.log"/> <VirtualHostGroup Name="foobarcom"> <VirtualHost Name="foo.bar.com"/> </VirtualHostGroup> <ServerCluster CloneSeparatorChange="false" LoadBalance="Round Robi +n" Name="cl_app302_prod" PostSizeLimit="-1" RemoveSpecialHeaders="tru +e" RetryInterval="60"> <Server CloneID="umjbf6mv" ConnectTimeout="0" ExtendedHandshake= +"false" LoadBalanceWeight="2" MaxConnections="-1" Name="swel3p_cl_app +302_prod" WaitForContinue="false"> <Transport Hostname="swel3p.bar.com" Port="8132" Protocol="ht +tp"/> </Server> <PrimaryServers> <Server Name="swel3p_sg_app302_prod"/> <Server Name="swel4p_sg_app302_prod"/> <Server Name="swel1r_sg_app302_prod"/> <Server Name="swel2r_sg_app302_prod"/> </PrimaryServers> </ServerCluster> <!-- APP URI groups point at urls --> <UriGroup Name="event/event.war_URIs"> <Uri AffinityCookie="JSESSIONID_302" Name="/event/*.jsp"/> <Uri AffinityCookie="JSESSIONID_302" Name="/event/ThreadedEven +tServlet"/> </UriGroup> <!-- Route statement bring it all together --> <Route ServerCluster="cl_app302_prod" UriGroup="event/event.war_URI +s" VirtualHostGroup="foobarcom"/> </Config>

Which on my systems produces:

<Config ASDisableNagle="false" AcceptAllContent="false" IISDisableNagl +e="false" IgnoreDNSFailures="false" RefreshInterval="60" ResponseChun +kSize="64"> <Log LogLevel="Error" Name="/opt/IBMWebAS/logs/native.log"/> <VirtualHostGroup Name="foobarcom"> <VirtualHost Name="foo.bar.com"/> </VirtualHostGroup> <ServerCluster CloneSeparatorChange="false" LoadBalance="Round Robi +n" Name="cl_app302_prod" PostSizeLimit="-1" RemoveSpecialHeaders="tru +e" RetryInterval="60"> <Server CloneID="umjbf6mv" ConnectTimeout="0" ExtendedHandshake= +"false" LoadBalanceWeight="2" MaxConnections="-1" Name="swel3p_cl_app +302_prod" WaitForContinue="false"> <Transport Hostname="swel3p.bar.com" Port="8132" Protocol="ht +tp"/> </Server> <PrimaryServers><Server Name="New_2"/><Server Name="New_1"/></Pr +imaryServers> </ServerCluster> <!-- APP URI groups point at urls --> <UriGroup Name="event/event.war_URIs"> <Uri AffinityCookie="JSESSIONID_302" Name="/event/*.jsp"/> <Uri AffinityCookie="JSESSIONID_302" Name="/event/ThreadedEven +tServlet"/> </UriGroup> <!-- Route statement bring it all together --> <Route ServerCluster="cl_app302_prod" UriGroup="event/event.war_URI +s" VirtualHostGroup="foobarcom"/> </Config>

-Nitrox


In reply to Re: Formatting in XML::Twig->print() by Nitrox
in thread Formatting in XML::Twig->print() by Nitrox

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (8)
As of 2024-04-19 14:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found