Compares two XML documents and returns the differences.
Compare-Xml.ps1 [-ReferenceXml] <XmlDocument> [-DifferenceXml] <XmlDocument>
[-ProgressAction <ActionPreference>] [<CommonParameters>]
' '<a b="y"/>' |Format-Xml.ps1
<xsl:transform version=”1.0” xmlns:xsl=”http://www.w3.org/1999/XSL/Transform”> <xsl:output omit-xml-declaration=”yes” method=”xml” /> <xsl:template match=”@|node()”> <xsl:copy> <xsl:apply-templates select=”@|node()” /> </xsl:copy> </xsl:template> <xsl:template match=”/a/@b”> <xsl:attribute name=”b”><![CDATA[y]]></xsl:attribute> </xsl:template> </xsl:transform>
' '<a c="y"/>' |Format-Xml.ps1
<xsl:transform version=”1.0” xmlns:xsl=”http://www.w3.org/1999/XSL/Transform”> <xsl:output omit-xml-declaration=”yes” method=”xml” /> <xsl:template match=”@|node()”> <xsl:copy> <xsl:apply-templates select=”@|node()” /> </xsl:copy> </xsl:template> <xsl:template match=”/a/@b” /> <xsl:template match=”/a”> <xsl:copy> <xsl:apply-templates select=”@*” /> <xsl:attribute name=”c”><![CDATA[y]]></xsl:attribute> </xsl:copy> </xsl:template> </xsl:transform>
<b/><c/><!-- d --></a>' '<a><c/><b/></a>' |Format-Xml.ps1
<xsl:transform version=”1.0” xmlns:xsl=”http://www.w3.org/1999/XSL/Transform”> <xsl:template match=”@|node()”> <xsl:copy> <xsl:apply-templates select=”@|node()” /> </xsl:copy> </xsl:template> <xsl:template match=”/a”> <xsl:copy> <xsl:apply-templates select=”@*” /> <xsl:apply-templates select=”c” /> <xsl:apply-templates select=”b” /> </xsl:copy> </xsl:template> </xsl:transform>
' '<a><!-- annotation --><new/><?node details?></a>' |Format-Xml.ps1
<xsl:transform version=”1.0” xmlns:xsl=”http://www.w3.org/1999/XSL/Transform”> <xsl:template match=”@|node()”> <xsl:copy> <xsl:apply-templates select=”@|node()” /> </xsl:copy> </xsl:template> <xsl:template match=”/a”> <xsl:copy> <xsl:comment><![CDATA[ annotation ]]></xsl:comment> <new /> <xsl:processing-instruction name=”node”><![CDATA[details]]></xsl:processing-instruction> </xsl:copy> </xsl:template> </xsl:transform>
The original XML document to be compared.
Type: XmlDocument
Parameter Sets: (All)
Aliases:
Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
An XML document to compare to.
Type: XmlDocument
Parameter Sets: (All)
Aliases:
Required: True
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Type: ActionPreference
Parameter Sets: (All)
Aliases: proga
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.