21.5. XML Tools

PowerShell offers really great XML support through its type adapters, but there is always room for improvement. One such example is pretty printing. Quite often, we get XML that is so horribly formatted that it is close to being unreadable. For example, here is how a snippet of the XHTML (HTML expressed as valid XML) code taken from the W3C looks:

PS> type unformatted.xml <div class="navBlock"> <h2 class="spot-head">W3C Technical Plenary</h2> <div class="spot-image"> <a href="http://www.bea.com/"> <img width="120" height="75" alt="BEA logo" src="/2007/11/TPAC/bea.png" /></a> </div> <div class="spot-image"> <a href="http://www.cisco.com/"> <img width="120" height="63" alt="Cisco logo" src="/2007/11/Cisco-logo.png" /></a> </div> ...

Get Pro Windows PowerShell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.