Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6204125
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:02:09+00:00 2026-05-24T05:02:09+00:00

I have an xml file which looks like the below example <Ids> <Id> <set>ai</set>

  • 0

I have an xml file which looks like the below example

<Ids>
   <Id>
      <set>ai</set>
      <idN>2000</idN>
      <Desc>Node</Desc>
      <tabs>
         <tab>
            <tabName>na</tabName>
            <tabAlias>na</tabAlias>
            <tabQualifier>SCH</tabQualifier>
         </tab>
      </tabs>
      <cls>
         <cl>
            <cName>def</cName>
            <cLName>term</clName>
            <clPos>0</clPos>
            <tabName>nodeassign</tabName>
            <clType>C</clType>
            <dName></dName>
            <dI>
               <dB>0</dB>
               <gd>0</gd>
               <gdgR></gdgR>
               <gCol></gCol>
            </dI>
         </cl>
         <cl>
            <cName>default</cName>
            <cLName>mux_id</cLName>
            <clPos>1</clPos>
            <tabName>nodeassign</tabName>
            <clType>I</clType>
            <dName></dName>
            <dI>
               <dB>0</dB>
               <gd>0</gd>
               <gdgR></gdgR>
               <gCol></gCol>
            </dI>
         </cl>
      </cls>
   </Id>
</Ids>

This is just a part of a large xml file. I have to compare two xml files and should be able to get out all the differences in two files to an separate xml. Should be able to change the values of few elements if they are different from the other xml file.

So to start with this I followed the approached suggested in the following link http://www.daniweb.com/software-development/csharp/threads/46345. But when I have generated a dataset for the given xml, there lots of tables created with in the dataset (like Ids, id, cls, cl, di, tabs…). I did not understand how to establish the relationships between the tables. Also did not understand which column in the generated tables becomes the primary key so that i can rely on it. The example provided in the above link is a simple xml so the author was able to solve the problem easily.

But the xml which I have is bit complex. Any help much appreciated.

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T05:02:09+00:00Added an answer on May 24, 2026 at 5:02 am

    I have followed similar solution specified in the given link and was able to solve my problem. But I am still working on it.

    When I have created a dataset and loaded my xml, the following relations are created in the dataset and with those I was able to navigate other rows. The relations that were created are as follows:

    Ids_Id
    Id_tabs
    tabs_tab
    Id_cls
    cls_cl
    

    The sample code for that is as follows:

    public void CompareXml()
    {
        DataSet xml1DS = new DataSet("Xml1");
        DataSet xml2DS = new DataSet("Xml2");   
        DataSet outputDS = new DataSet("Output");       
    
        //read in our files
        try
        {
            xml1DS.ReadXml(@"C:\xml1.xml", XmlReadMode.Auto);
            xml2DS.ReadXml(@"C:\xml2.xml", XmlReadMode.Auto);
        }
        catch (Exception)
        {
    
        }
    
        outputXML = xml2DS;
    
        IEqualityComparer<DataRow> comparer = DataRowComparer.Default;
    
        foreach (DataRow row1 in xml1DS.Tables["Id"].Rows)
        {
            bool hasRow = false;
            foreach (DataRow row2 in xml2DS.Tables["Id"].Rows)
            {
                try
                {
                    if ((string)row1["idN"] == (string)row2["idN"])
                    {
                        DataRow[] Child1 = row1.GetChildRows("Id_cls")[0].GetChildRows("cls_cl");
                        DataRow[] Child2 = row2.GetChildRows("Id_cls")[0].GetChildRows("cls_cl");
    
                        foreach (var v in Child1)
                        {
                            foreach (var t in Child2)
                            {
                                //string str = v.GetParentRow("columns_column").GetParentRow("configId_columns")["idNumber"].ToString();
    
    
                                if ((v["clPos"].ToString() == t["clPos"].ToString()) &&
                                    (v["cLName"].ToString() == t["cLName"].ToString())
                                    )
                                {
                                    hasRow = true;
    
                                    if (IsColumnNodeEqual(v, t) == false)
                                    {
                                        t["cName"] = "###";
                                    }
                                    break;
                                }
                            }
                        }
                    }
                }
                catch(Exception)
                {
                }
    
            }
    
            if(!hasRow) 
            {
    
            }
        }
    
        //write it to the xml file
        outputXML.WriteXml("newXML.xml");
    
     }
    

    Even though the approach is inefficient but I have got easy to extend and maintainable code. Any how this code is just for writing a tool for one of my xmls.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have sitemap which looks like this: <?xml version=1.0 encoding=utf-8 ?> <siteMap xmlns=http://schemas.microsoft.com/AspNet/SiteMap-File-1.0 >
I have created an extension method called AddGZip which looks like the following: public
Hay, i have a flash movie which loads a static XML file, the script
I am trying to use URLLoader to load an XML file from server (same
I'm trying to create an XML output file to import into another program. The
I have found some similar questions like this one, however there are so many
In Spring web mvc 1) If we define DispatcherServlet as below <servlet> <servlet-name>appServlet</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
I have created a custom Ant task as per one of my previous posts
I am new to webservices in general. I am trying to write a Java
Here's the problem in a nutshell: <bean id=handlerFactory class=com.westfieldgrp.audit.jdklogging.cpm.CPMHandlerFactory> <property name=schemaName value=${env.audit.databaseSchema} /> <property

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.