perlquestion
TheVend
<p>
I am parsing XML and need a script that will read my XML file and add in the open tag for all missing open tags.
Example from XML below: <promo_code/> has no matching open tag <promo_code> I need the code to scan and add missing open tags. End result would be <promo_code> <promo_code/>
Example XML code below…
</p>
<code>
<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/>
<billing_address>
<address_id/>
<dd_customer_id/>
<address_1>1212 Not Real</address_1>
<address_2></address_2>
<city>san mateo</city>
<title></title>
<company></company>
<first_name>Jane</first_name>
<last_name>Doe</last_name>
<state_abbr/>
<formated_telephone/>
<zipcode/>
<email>smith@smith.com</email>
<country_code>USA</country_code>
</billing_address>
<transaction>
</transaction>
<shipments>
<shipment_id>21286</shipment_id>
<shipment>
<shipping_address>
<address_id>27696</address_id>
<dd_customer_id/>
<address_1>1212 Not Real</address_1>
<address_2></address_2>
<city>san jose</city>
<title>Dr</title>
<company></company>
<first_name>Jane</first_name>
<last_name>Doe</last_name>
<state_abbr>CA</state_abbr>
<formated_telephone>555-555-5555 Jane Smith</formated_telephone>
<zipcode>95125-3344</zipcode>
<email></email>
<country_code>USA</country_code>
</shipping_address>
<delivery_date>2011-10-01</delivery_date>
<gift>true</gift>
<gift_email>smith@smith.com</gift_email>
<gift_message>Happy Birthday</gift_message>
<status>N</status>
<tracking_nr></tracking_nr>
<sent_at/>
</shipment>
</shipments>
<line_items>
<line_item>
<line_item_id>16821</line_item_id>
<dd_id>IDID</dd_id>
<name>Keep It Coming</name>
<quantity>1</quantity>
<price>359.0</price>
<shipment_id>21286</shipment_id>
<shipping_costs>90.0</shipping_costs>
<tax_amount>0</tax_amount>
</line_item>
</line_items>
</order>
<orders>
</code>