|
-
Apr 29th, 2004, 03:57 PM
#1
Thread Starter
Member
Compare two XML files
Hi there!
Does anyone know how to compare two xml files?
what i wanna do is compare the two xml Files and then display the difference to the datagrid...thanks in advance.
-
Apr 30th, 2004, 06:38 AM
#2
I wonder how many charact
You could probably get away with writing XSL that would be the envy of your peers:
VB Code:
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml"/>
<xsl:variable name="doc-file">[url]http://mymachine.com/changed.xml[/url]</xsl:variable>
<!-- copy everything that has no other pattern defined -->
<xsl:template match="* | @*">
<xsl:copy><xsl:copy-of select="@*"/><xsl:apply-templates/></xsl:copy>
</xsl:template>
<!-- check for every <address> element if an updated one exists -->
<xsl:template match="//address">
<xsl:param name="addresseeName">
<xsl:value-of select="addressee"/>
</xsl:param>
<xsl:choose>
<xsl:when test="document($doc-file)//addressee[text()=$addresseeName]">
<xsl:copy-of select="document($doc-file)//address[child::addressee[text()=$addresseeName]]"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
But that's mind-numbing stuff and I certainly wouldn't be able to help you.
-
Apr 30th, 2004, 06:48 AM
#3
I wonder how many charact
You can use .Net xml classes to find the differences, but differences really depend on the structure of the XML documents in queston.
I mean I could have
Code:
<root>
<Address>
<AddressID>1</AddressID>
<StreetNumber>111</StreetNumber>
</Address>
<Address>
...
and
Code:
<root>
<Address>
<AddressID>1</AddressID>
<StreetNumber>123</StreetNumber>
</Address>
<Address>
...
And you could certainly tell that for the Address uniquely identified by 1, there is a difference in the two XML documents (the streetnumber is differen).
Or, it could be that the 2nd XML document has a different address structure :
Code:
<root>
<Address>
<AddressID>1</AddressID>
<StreetNumber>111</StreetNumber>
<StreetName>Franklin</StreetName>
</Address>
<Address>
...
in which case the difference would be this 2nd file has a StreetName child attribute.
So, which is the one you want?
-
Apr 30th, 2004, 10:16 AM
#4
Thread Starter
Member
i guess the first example of the xml document is what i am looking for. what i'm doing is scanning a computer for software. and then after a few days later scan the machine again. and then compare the two scans. i'm writing the files as xml schemas....thanks
Last edited by dawgfather; Apr 30th, 2004 at 10:21 AM.
-
May 2nd, 2004, 10:37 AM
#5
Fanatic Member
I suppose you want .NET code to compare XML files but in the meantime have a look at this tool XML Diff Demo
Using VB.NET 2003/.NET 1.1/C# 2.0
http://del.icio.us/rajoo
Blow your mind, smoke gunpowder
Ashes to ashes, dust to dust
If God won't have you, the devil will. - Author unknown
Don't follow me, I'm lost too ...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|