XML Comparison?
Posted
by CrazyNick
on Stack Overflow
See other posts from Stack Overflow
or by CrazyNick
Published on 2010-03-16T08:34:36Z
Indexed on
2010/03/16
8:36 UTC
Read the original article
Hit count: 397
I got a books.xml file from http://msdn.microsoft.com/en-us/library/ms762271(VS.85).aspx and just saved it with two different names, removed few lines from the second file and tried to compare the files using the below powershell code:
clear-host $xml = New-Object XML $xml = [xml](Get-Content D:\SharePoint\Powershell\Comparator\Comparator_Config.xml) $xml.config.compare | ForEach-Object { $strFile1 = get-Content $.source; $strFile2 = get-Content $.destination; $diff = Compare-Object $strFile1
$strFile2; $result1 = $diff | where {$.SideIndicator -eq "<=" } | select InputObject; $result2 = $diff | where {$.SideIndicator -eq "=>" } | select
InputObject; Write-host "nEntries are differ in First web.config file
n"; $result1 | ForEach-Object {write-host $.InputObject}; Write-host "nEntries are differ in Second web.config file
n" ;$result2 | ForEach-Object {write-host $.InputObject}; $.parameters | ForEach-Object { write-host $.parameter } }
and it is working perfectly and giving me the below results:
Entries are differ in First web.config file < price>36.95< /price> < description>Microsoft Visual Studio 7 is explored in depth, looking at how Visual Basic, Visual C++, C#, and ASP+ are integrated into a comprehensive development environment.< /description>
Entries are differ in Second web.config file < price>< /price> < description>< /description>
however I wan to know the root node of the above mentioned nodes, is that possible to find? if so, how?
© Stack Overflow or respective owner