# Comparing XML

**URL:** <https://forums.powershell.org/t/comparing-xml/10488>\
**Category:** PowerShell Help\
**Created:** [April 11, 2018, 3:41am UTC](https://forums.powershell.org/t/comparing-xml/10488 "2018-04-11T03:41:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jarek-c](https://avatars.discourse-cdn.com/v4/letter/j/e56c9b/32.png) [@jarek-c](https://forums.powershell.org/u/jarek-c)\
**Post date:** [April 11, 2018, 3:41am UTC](https://forums.powershell.org/t/comparing-xml/10488/1 "2018-04-11T03:41:46Z")

</div>

I’m trying to compare 2 xml files where I create both using HP conrep. This is to check if all systems have the same bios setup. I read them doing [xml]$bios = get-content c:\dif.xml and further $reference = $bios.Conrep.Section|select name,‘#text’. Similarly I go with $difference where I extract from [xml]$biosDif. I then compare both $reference and $difference running compare-object. Often I get no output which in my script sets the success value to true. However by chance I found that sometimes even though the contents of the 2 xmls will differ compare-object won’t return anything. My $difference and $reference objects are of Selected.System.XML.XmlElement

---

<div class="post-metadata">

**Author:** ![chris-bakker](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/chris-bakker/32/6356_2.png) [@chris-bakker](https://forums.powershell.org/u/chris-bakker)\
**Post date:** [April 11, 2018, 5:46am UTC](https://forums.powershell.org/t/comparing-xml/10488/2 "2018-04-11T05:46:07Z")

</div>

Try this:

```
Compare-Object $(Get-Content c:\test1.xml) $(Get-Content c:\test2.xml) -includeequal
```

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:36pm UTC](https://forums.powershell.org/t/comparing-xml/10488/3 "2024-05-16T20:36:00Z")

</div>

Closed on May 16, 2024, 8:36pm UTC


