Splitting based on an XML element value
Posted: Thu Oct 18, 2007 9:27 pm
I am trying to split the following type of XML Order using textpipe:-
<Message>
<Head>
</Head>
<Body>
<OrderHeader>
<OrderDetail><Value>A</Value><Info>ABC</Info></OrderDetail>
<OrderDetail><Value>A</Value><Info>DEF</Info></OrderDetail>
<OrderDetail><Value>B</Value><Info>GHI</Info></OrderDetail>
<OrderDetail><Value>B</Value><Info>JKL</Info></OrderDetail>
</OrderHeader>
</Body>
</Message>
What I want out is :-
File 1
<Message>
<Head>
</Head>
<Body>
<OrderHeader>
<OrderDetail><Value>A</Value><Info>ABC</Info></OrderDetail>
<OrderDetail><Value>A</Value><Info>DEF</Info></OrderDetail>
</OrderHeader>
</Body>
</Message>
and File 2
<Message>
<Head>
</Head>
<Body>
<OrderHeader>
<OrderDetail><Value>B</Value><Info>GHI</Info></OrderDetail>
<OrderDetail><Value>B</Value><Info>JKL</Info></OrderDetail>
</OrderHeader>
</Body>
</Message>
I know how to get the <Head> and </OrderHeader> etc info into the split files but I don't know how to group the <OrderDetail> together by <Value> and then split it since we could have any number of these <OrderDetail> tags with any value of <Value>.
Any ideas?
thanks
<Message>
<Head>
</Head>
<Body>
<OrderHeader>
<OrderDetail><Value>A</Value><Info>ABC</Info></OrderDetail>
<OrderDetail><Value>A</Value><Info>DEF</Info></OrderDetail>
<OrderDetail><Value>B</Value><Info>GHI</Info></OrderDetail>
<OrderDetail><Value>B</Value><Info>JKL</Info></OrderDetail>
</OrderHeader>
</Body>
</Message>
What I want out is :-
File 1
<Message>
<Head>
</Head>
<Body>
<OrderHeader>
<OrderDetail><Value>A</Value><Info>ABC</Info></OrderDetail>
<OrderDetail><Value>A</Value><Info>DEF</Info></OrderDetail>
</OrderHeader>
</Body>
</Message>
and File 2
<Message>
<Head>
</Head>
<Body>
<OrderHeader>
<OrderDetail><Value>B</Value><Info>GHI</Info></OrderDetail>
<OrderDetail><Value>B</Value><Info>JKL</Info></OrderDetail>
</OrderHeader>
</Body>
</Message>
I know how to get the <Head> and </OrderHeader> etc info into the split files but I don't know how to group the <OrderDetail> together by <Value> and then split it since we could have any number of these <OrderDetail> tags with any value of <Value>.
Any ideas?
thanks