XML Comparison?
- by CrazyNick
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 filen"; $result1 | ForEach-Object {write-host $.InputObject}; Write-host "nEntries are differ in Second web.config filen" ;$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
< price36.95< /price
< descriptionMicrosoft 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?