BizTalk Server Talk

My experiences with BizTalk Server

How to debatch a xml file

I searched the internet to find ways to debatch an xml file and found a way to do the same.

I did not write a custom pipeline component to achieve the same.

What I did is wrote a method which accepts the xpath of the node , you want to debatch , its current node ,count and xml document.

c#

public void batchSplitter(xmldocument xDoc, string xPathOf Node,string xPathOfParent,int index)

//take a back up of the node which you want to retain

XmlNode xmlnodetoInsert;

xmlnode backUpNode =xDoc.selectsinglenode(xPathOf Node + “[" + index + "]” );

xmlnodetoInsert = backUpNode ;

//remove all the nodes from the parent

xmlnode node =xDoc.selectsinglenode(xPathOf Node + “[" + index + "]” );

node.Parentnode.removeall();

//now get the parent node

XmlNode xmlRequestNode = xDoc.SelectSingleNode(xPathOfParent )

//now append the backed up node

parentNode.appendchild(backUpNode);

End method

In the orchestration designer get the count of the nodes (Item) which you are planning to debatch,Ex

nodeCount = System.Convert.ToInt32(xpath(yourXmlMessage, “count(//Item)”));

add a loop shape to the orchestration..

call the method by sending the input message along with the count i.e. nodecount

decrement the nodeCount by 1

loop untill nodeCount > 0

The above concept works for flat files too, just send the xml document created by flat file schema.

Let me know if you have questions.

December 24, 2007 - Posted by biztalkservertalk | concepts, xml | , , | No Comments Yet

No comments yet.

Leave a comment