Avatar of pothireddysunil
pothireddysunil
 asked on

Read an XML file between a repetative nodes and create new xml files from it

I have an xml file. Here I need to read the elements between ImportDocument starting and ending nodes and create a new xml document with those elements and its values. So, for the below xml file, I need to create 3 new xml files.

But before creating a new xml document I need to get values from database for Pernsr and SubmittingPernr element values.

Can anyone has any sample code for this task?

<?xml version="1.0" encoding="UTF-8"?>
-<DmHrImport xsi:noNamespaceSchemaLocation="http://dm-corp.swna.wdpr.disney.com/ImportSchemas/DmHrImport.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
-<Feed>
      <Interface>000001</Interface>
      <Version>001</Version>
</Feed>
-<Options>
      <Test>N</Test>
      <BatchName>00000120140528502</BatchName>
</Options>
-<ImportDocument>
      <Pernr>00895722</Pernr>
      <SubmittingPernr>00895722</SubmittingPernr>
      <Type>APPLMAT</Type>
      <Application>ACROBAT</Application>
      <FilePath>\files\0000\00895722_1_Emergency Contact Information.pdf</FilePath>
      <DocumentDate>2014-05-15</DocumentDate>
      <Notes/>
</ImportDocument>
-<ImportDocument>
      <Pernr>00895722</Pernr>
      <SubmittingPernr>00895722</SubmittingPernr>
      <Type>APPLMAT</Type>
      <Application>ACROBAT</Application>
      <FilePath>\files\0000\00895722_2_Release of Info & Documentation(College).pdf</FilePath>
      <DocumentDate>2014-05-15</DocumentDate>
      <Notes/>
</ImportDocument>
-<ImportDocument>
      <Pernr>00891102</Pernr>
      <SubmittingPernr>00891102</SubmittingPernr>
      <Type>APPLMAT</Type>
      <Application>ACROBAT</Application>
      <FilePath>\files\0000\00891102_3_Emergency Contact Information.pdf</FilePath>
      <DocumentDate>2014-05-11</DocumentDate>
      <Notes/>
</ImportDocument>
</DmHrImport>
C#.NET Programming

Avatar of undefined
Last Comment
Fernando Soto

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Fernando Soto

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
toakkiyadav

I suspect this is some kind of batch process and importdocument tags would be in good numbers.
Pernr and SubmittingPernr are look up values

My approach would be -
1. Query database and spit out an xml which will server as lookup xml.
2. Use XSLT to break batch xml file into multiple xml files.

Below url's should help you in achieving #2.
http://stackoverflow.com/questions/4181496/xslt-output-into-multiple-xml-files-based-on-grouping
http://stackoverflow.com/questions/19021205/merging-two-xml-files-using-xslt

thanks
pothireddysunil

ASKER
Thanks
Fernando Soto

Not a problem, glad I was able to help.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck