Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
XML::Twig empty_tags => 'expand' looks like it does what you want. I shortened your XML and fixed the closing "orders tag":
use warnings; use strict; use XML::Twig; my $xml = <<XML; <orders> <order> <alt_number>2222</alt_number> <state>processed</state> <user_id>1234</user_id> <dd_id>54321</dd_id> <placed_at/> <total_price>449.0</total_price> <total_shipping_costs>90.0</total_shipping_costs> <discount>0</discount> <dd_status_code>HD</dd_status_code> <dd_status_desc>ORDER IS ON HOLD UNTIL 11/01/13</dd_status_desc> <promo_code/> </order> </orders> XML my $twig = XML::Twig->new( pretty_print => 'indented', empty_tags => 'expand', ); $twig->parse($xml); $twig->print; __END__ Output: <orders> <order> <alt_number>2222</alt_number> <state>processed</state> <user_id>1234</user_id> <dd_id>54321</dd_id> <placed_at></placed_at> <total_price>449.0</total_price> <total_shipping_costs>90.0</total_shipping_costs> <discount>0</discount> <dd_status_code>HD</dd_status_code> <dd_status_desc>ORDER IS ON HOLD UNTIL 11/01/13</dd_status_desc> <promo_code></promo_code> </order> </orders>

In reply to Re: How can I add missing XML open tags by toolic
in thread How can I add missing XML open tags by TheVend

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? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2022-12-07 10:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?