DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Comparing XML's

  1. #1
    Alex Kennedy Guest

    Comparing XML's



    Hi,

    I'm having a slight problem comparing XML's... I am using MS XML 4 to manipulate
    XML data e.g.

    <CAR colour="red" wheels="4">
    <PASSENGER name="fred" />
    <PASSENGER name="wilma" />
    </CAR>

    If I remove the two PASSENGER elements my resulting XML is:

    <CAR colour="red" wheels="4">
    </CAR>

    Is there anything I do in the MS XML parser to refresh/rebuild the XML so
    that it becomes:

    <CAR colour="red" wheels="4" />

    The problem is that I compare XML's as strings after the manipulation to
    see if they are the same or not. I don't care what the difference is, I
    just need to know that there is a difference.

    Alternatively is there any COM components out there for comparing XML's?
    I've seen something from MS but it requires the .Net framework so I wouldn't
    be allowed to use it anyway.

    Thanks

    Alex



  2. #2
    Marian Olteanu Guest

    Re: Comparing XML's


    I have in mind two ways to solve your problem:
    - use DOM API to traverse the two parsed trees
    - use a really simple XSLT stylesheet (I think that it will have around 30
    lines) to do the job: one XML is the input source for the XSLT, the other
    one is loaded by document() function - the name is received as a parameter.
    "Alex Kennedy" <kenna2@bp.com> wrote:
    >
    >
    >Hi,
    >
    >I'm having a slight problem comparing XML's... I am using MS XML 4 to manipulate
    >XML data e.g.
    >
    ><CAR colour="red" wheels="4">
    > <PASSENGER name="fred" />
    > <PASSENGER name="wilma" />
    ></CAR>
    >
    >If I remove the two PASSENGER elements my resulting XML is:
    >
    ><CAR colour="red" wheels="4">
    ></CAR>
    >
    >Is there anything I do in the MS XML parser to refresh/rebuild the XML so
    >that it becomes:
    >
    ><CAR colour="red" wheels="4" />
    >
    >The problem is that I compare XML's as strings after the manipulation to
    >see if they are the same or not. I don't care what the difference is, I
    >just need to know that there is a difference.
    >
    >Alternatively is there any COM components out there for comparing XML's?
    > I've seen something from MS but it requires the .Net framework so I wouldn't
    >be allowed to use it anyway.
    >
    >Thanks
    >
    >Alex
    >
    >



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center