Hey guys!

Today’s blog post is a quick Powershell tip which is useful when we’ve to generate Dynamic XML using a Powershell script, if the file gets huge it gets difficult to read the XML data , hence in such a case Indentation comes handy.

HOW TO MAKE IT WORK ?

Use System.IO.StringWriter and System.XMl.XmlTextWriter classes to build/write a XML string in an underlying String builder, containing XML data that complies with W3C (World wide web consortium) XML 1.0 standards.

You’ve just take care about two XmlTextWriter properties to indent your XML’s, those are

Make sure you make the property Formatting as indented and provide an positive integer value to Indentation property for number of chars to write for each level in XML hierarchy.

SCRIPT :

Hoping this would be useful for you, Thanks for reading ! 🙂

Prateek Singh