Use XSLT:
#transform to HTML report
$xslt=New-Object System.Xml.Xsl.XslCompiledTransform
$xslt.Load("$pwd\transform.xsl")
$xslt.Transform("$pwd\original.xml","$pwd\result.xml")
Com a folha de estilo a seguir:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml"
>
<xsl:template match="node()" mode="print">
<xsl:choose>
<!-- is it element? -->
<xsl:when test="name()">
<br />
<!-- start tag -->
<xsl:text><</xsl:text>
<xsl:value-of select="name()" />
<!-- attributes -->
<xsl:apply-templates select="@*" mode="print" />
<xsl:choose>
<!-- has children -->
<xsl:when test="node()">
<!-- closing bracket -->
<xsl:text>></xsl:text>
<!-- children -->
<xsl:apply-templates mode="print" />
<!-- end tag -->
<xsl:text></</xsl:text>
<xsl:value-of select="name()" />
<xsl:text>></xsl:text>
<br />
</xsl:when>
<!-- is empty -->
<xsl:otherwise>
<!-- closing bracket -->
<xsl:text>/></xsl:text><br />
<br />
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<!-- text -->
<xsl:otherwise>
<xsl:copy />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="@*" mode="print">
<xsl:text> </xsl:text>
<xsl:value-of select="name()" />
<xsl:text>="</xsl:text>
<xsl:value-of select="." />
<xsl:text>"</xsl:text>
</xsl:template>
<xsl:template match="text()" mode="print">
<xsl:choose>
<xsl:when test="contains(parent::node()/@key, 'Availability')">
<xsl:value-of select="number(current()) + 1" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="." />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="/">
<xsl:apply-templates mode="print" />
</xsl:template>
</xsl:stylesheet>
Que produz a seguinte saída:
Como eu emito a representação XML de escape de um nó na saída HTML do meu XSLT - estouro de pilha -
Convertendo XML em texto com escape no XSLT - Stack Overflow
-
PowerShell prático Processos com SQL Change Automation - Redgate Software
-
comentários técnicos: relatórios do PowerShell com XML - parte 1