I have a large xml document that needs to be processed 100 records at a time
It is being done within a Windows Service written in c#.
The structure is as follows :
<docket xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:noNamespaceSchemaLocation='docket.xsd'> <order> <Date>2008-10-13</Date> <orderNumber>050758023</orderNumber> <ParcelID/> <CustomerName>sddsf</CustomerName> <DeliveryName>dsfd</DeliveryName> <Address1>sdf</Address1> <Address2>sdfsdd</Address2> <Address3>sdfdsfdf</Address3> <Address4>dffddf</Address4> <PostCode/> </order> <order> <Date>2008-10-13</Date> <orderNumber>050758023</orderNumber> <ParcelID/> <CustomerName>sddsf</CustomerName> <DeliveryName>dsfd</DeliveryName> <Address1>sdf</Address1> <Address2>sdfsdd</Address2> <Address3>sdfdsfdf</Address3> <Address4>dffddf</Address4> <PostCode/> </order> ..... ..... </docket>
There could be thousands of orders in a docket.
I need to chop this into 100 element chunks
However each of the 100 orders still need to be wrapped with the parent ‘docket’ node and have the same namespace etc
is this possible?
Another naive solution; this time for .NET 2.0. It should give you an idea of how to go about what you want. Uses Xpath expressions instead of Linq to XML. Chunks a 100 order docket into 10 dockets in under a second on my devbox.