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:noNamespaceSchemaLocat ion="http://dm-corp.swna.wdpr.disney.com/ImportSchemas/DmHrImport.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
-<Feed>
<Interface>000001</Interfa ce>
<Version>001</Version>
</Feed>
-<Options>
<Test>N</Test>
<BatchName>000001201405285 02</BatchN ame>
</Options>
-<ImportDocument>
<Pernr>00895722</Pernr>
<SubmittingPernr>00895722< /Submittin gPernr>
<Type>APPLMAT</Type>
<Application>ACROBAT</Appl ication>
<FilePath>\files\0000\0089 5722_1_Eme rgency Contact Information.pdf</FilePath>
<DocumentDate>2014-05-15</ DocumentDa te>
<Notes/>
</ImportDocument>
-<ImportDocument>
<Pernr>00895722</Pernr>
<SubmittingPernr>00895722< /Submittin gPernr>
<Type>APPLMAT</Type>
<Application>ACROBAT</Appl ication>
<FilePath>\files\0000\0089 5722_2_Rel ease of Info & Documentation(College).pdf </FilePath >
<DocumentDate>2014-05-15</ DocumentDa te>
<Notes/>
</ImportDocument>
-<ImportDocument>
<Pernr>00891102</Pernr>
<SubmittingPernr>00891102< /Submittin gPernr>
<Type>APPLMAT</Type>
<Application>ACROBAT</Appl ication>
<FilePath>\files\0000\0089 1102_3_Eme rgency Contact Information.pdf</FilePath>
<DocumentDate>2014-05-11</ DocumentDa te>
<Notes/>
</ImportDocument>
</DmHrImport>
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:noNamespaceSchemaLocat
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
-<Feed>
<Interface>000001</Interfa
<Version>001</Version>
</Feed>
-<Options>
<Test>N</Test>
<BatchName>000001201405285
</Options>
-<ImportDocument>
<Pernr>00895722</Pernr>
<SubmittingPernr>00895722<
<Type>APPLMAT</Type>
<Application>ACROBAT</Appl
<FilePath>\files\0000\0089
<DocumentDate>2014-05-15</
<Notes/>
</ImportDocument>
-<ImportDocument>
<Pernr>00895722</Pernr>
<SubmittingPernr>00895722<
<Type>APPLMAT</Type>
<Application>ACROBAT</Appl
<FilePath>\files\0000\0089
<DocumentDate>2014-05-15</
<Notes/>
</ImportDocument>
-<ImportDocument>
<Pernr>00891102</Pernr>
<SubmittingPernr>00891102<
<Type>APPLMAT</Type>
<Application>ACROBAT</Appl
<FilePath>\files\0000\0089
<DocumentDate>2014-05-11</
<Notes/>
</ImportDocument>
</DmHrImport>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks
Not a problem, glad I was able to help.
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