Community discussion forum

combine two xml files having different schemas to produce one xml file using ADO.net

  • 1 year ago

    HI Friends,

    I have a requirement to combine two xml files having different schemas to produce one xml

    file .Plz find the xml structures below:

    The input XML is in the form
     
    <EMPLOYEE>
    <EMPFNAME>ANIL</EMPFNAME>
    <EMPLNAME>JOSHI</EMPLNAME>
    <EMPCODE>213</EMPCODE>
    <MANAGEREMPCODE>211</MANAGEREMPCODE>
    <SALARY>5000</SALARY>
    <DEPT>FINANCE</DEPT>
    </EMPLOYEE>
     
    Assume that for each Employee in the company there is a XML of the structure above lying

    in a source folder.We have to read all the XMLs and create a single XML of the structure

    as below.
     
    <COMPANY>
    <DEPT NAME='FINANCE'>
    <MANAGER>AJIT MAHUT</MANAGER>
    <EMPLOYEE>ANIL JOSHI</EMPLOYEE
    <EMPLOYEE>SRIKANTH SINGH</EMPLOYEE>
    <EMPLOYEE>KAMAL ADNAN/EMPLOYEE
    </DEPT>
    <DEPT NAME='MIS'>
    <MANAGER>SAM PITRODA</MANAGER>
    <EMPLOYEE>ANIL KAPOOR</EMPLOYEE>
    <EMPLOYEE>MANGAL PANDEY</EMPLOYEE>
    <EMPLOYEE>R MADHAVAN</EMPLOYEE>
    </DEPT>
    </COMPANY>

    How will I do this? How can we do this using ADO.net ?
    Plz direct me.
    Regards
    A Sunil

     

  • 1 year ago

     

    try http://www.w3schools.com/XPath/default.asp and http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx in short, xpath and XmlDocument object are the easiest way to do this. you can google for the functions SelectNodes and SelectSingleNodes will run your xpath expressions.

     alternatively, you can create an xslt http://www.w3schools.com/xsl/ and then just use the XmlDocument to process the xslt and the xml together.

Post a reply

Enter your message below

Sign in or Join us (it's free).

We'd love to hear what you think! Submit ideas or give us feedback