Need to Split Big XML into multiple xmls

Dfd / Dfdf
October 28, 2010 at 02:41:57
Specs: unix, 2gb
Hi friends..
We have urgent requirement.We need to split the big xml having multiple orders into multiple xmls
having each order in each xml.
For Example
In input XMl will be in following format with multiple line orders..


<OrderDetail BillToKey="20100805337" Createuserid="CreateGuestOrder" >
<Order Number="1">
<OrderLine CarrierServiceCode="G2" FulfillmentType="ShipToHome"/>
<Item ItemDesc="iPearl 8GB MP3 " ItemID="11239924" ItemWeight="0.00" />
<LinePriceInfo ActualPricingQty="1.00" BundleTotal="0.00" DiscountPercentage="0.00" LineTotal="80.79" />
</Order>
<Order Number="2">
<OrderLine CarrierServiceCode="H2" FulfillmentType="ShipToHome" />
<Item ItemDesc="TV" ItemID="112345424" ItemWeight="67.00" />
<LinePriceInfo ActualPricingQty="1.00" BundleTotal="0.00" DiscountPercentage="0.00" LineTotal="80.79" />
</Order>
<Order Number="3">
<OrderLine CarrierServiceCode="M2" FulfillmentType="ShipToHome" />
<Item ItemDesc="TV" ItemID="4545345" ItemWeight="67.00" />
<LinePriceInfo ActualPricingQty="6.00" BundleTotal="0.00" DiscountPercentage="0.00" LineTotal="80.79" />
</Order>
</OrderDetail>


Output should:
Here we want to split this xml into 3 xmls.
Ist xml should contain Order Number=1 and 2nd xml will have Order Number=2 and so on...

Thanks & Regards
Prakash


See More: Need to Split Big XML into multiple xmls

Report •

#1
October 28, 2010 at 12:16:41
Try the unix csplit command:

csplit -s -k -f tt. dfile.txt "/^<Order Number*/" {90}

ignore this error:

csplit: {90} - out of range

It just means csplit did not create 90 files. increase the number within the curly braces if 90 files is not enough. Careful .... some versions of csplit only support up to 100 files. check your man page for more info.


Report •
Related Solutions


Ask Question