0
Reply

How to do XML Flattening for this XML

Sibeesh Venu

Sibeesh Venu

Nov 19 2014 11:44 AM
631
Hi All,
I have an XML as follows.

<?xml version="1.0" encoding="utf-8"?>
<cpeif:CustomerProfileResponse profileName="CustomerInformation" version="100" 
xmlns:cpeif=""
xmlns:ppns=""
xmlns:tpns="">

<cpeif:Person>
<ppns:CustID>1</ppns:CustID>
<ppns:CPrefix>CPrefix3</ppns:CPrefix>
<ppns:CFName>CFName3</ppns:CFName>
<ppns:CMName >CMName3</ppns:CMName>
<ppns:CLName>CLName3</ppns:CLName>
</cpeif:Person>
<cpeif:TransactionDetail>
<tpns:CHHID>0</tpns:CHHID>
<tpns:Transactions>
<tpns:Transaction>
<tpns:StoreID>0</tpns:StoreID>
<tpns:CustID>1</tpns:CustID>
<tpns:Item>Item1</tpns:Item>
</tpns:Transaction>
<tpns:Transaction>
<tpns:StoreID>4294967295</tpns:StoreID>
<tpns:CustID>1</tpns:CustID>
<tpns:Item>Item2</tpns:Item>
</tpns:Transaction>
<tpns:Transaction>
<tpns:StoreID>1</tpns:StoreID>
<tpns:CustID>1</tpns:CustID>
<tpns:Item>Item3</tpns:Item>
</tpns:Transaction>
</tpns:Transactions>
</cpeif:TransactionDetail>
</cpeif:CustomerProfileResponse>

I need to make it as the following

<?xml version="1.0" encoding="utf-8"?>
<cpeif:CustomerProfileResponse xmlns="mynamespace" profileName="CustomerInformation" version="100"
xmlns:cpeif=""
xmlns:ppns=""
xmlns:tpns=""
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>
<cpeif:Customer>
<ppns:CustID>1</ppns:CustID>
<ppns:CPrefix>CPrefix3</ppns:CPrefix>
<ppns:CFName>CFName3</ppns:CFName>
<ppns:CMName >CMName3</ppns:CMName>
<ppns:CLName>CLName3</ppns:CLName>
<tpns:StoreID>1</tpns:StoreID>
<tpns:CustID>1</tpns:CustID>
<tpns:SOrderNo>0</tpns:SOrderNo>
<tpns:Date>0</tpns:Date>
<tpns:Item>Item1</tpns:Item>
</cpeif:Customer>
<cpeif:Customer>
<ppns:CustID>1</ppns:CustID>
<ppns:CPrefix>CPrefix3</ppns:CPrefix>
<ppns:CFName>CFName3</ppns:CFName>
<ppns:CMName >CMName3</ppns:CMName>
<ppns:CLName>CLName3</ppns:CLName>
<tpns:StoreID>4294967295</tpns:StoreID>
<tpns:CustID>1</tpns:CustID>
<tpns:SOrderNo>4294967295</tpns:SOrderNo>
<tpns:Date>4294967295</tpns:Date>
<tpns:Item>Item2</tpns:Item>
</cpeif:Customer>
<cpeif:Customer>
<ppns:CustID>1</ppns:CustID>
<ppns:CPrefix>CPrefix3</ppns:CPrefix>
<ppns:CFName>CFName3</ppns:CFName>
<ppns:CMName >CMName3</ppns:CMName>
<ppns:CLName>CLName3</ppns:CLName>
<tpns:StoreID>1</tpns:StoreID>
<tpns:CustID>1</tpns:CustID>
<tpns:SOrderNo>2</tpns:SOrderNo>
<tpns:Date>1</tpns:Date>
<tpns:Item>Item3</tpns:Item>
</cpeif:Customer>
</cpeif:CustomerProfileResponse>

Here customer is doing 3 different transaction, so i need to show as three different tabs.Can any one help me doing this. Any help is appreciated. Thanks in advance.
Kindest Regards
Sibeesh