Pretty print xml

Hi,

I have a long xml stg like:
<block1>gj</block1><block2>fhh</block2>..,

Open in new window


The nodes names varies, there are children. All i need to do is pretty print it, like indenting.

I know i can pretty print with notepad++ but the gist is not opening it but supplying the xml file to a simple cmd exe.

Any open source light exe?

Br
LVL 12
jazzIIIloveAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David Johnson, CD, MVPOwnerCommented:
xml doesn't care about looking nice it is simply data. programs that consume xml also don't care about nice formatting it is between the <> and the </> that is important
0
jazzIIIloveAuthor Commented:
Hi,

I am asking this question for readability of a file perspective.
Essentially notepad++ has the functionality to pretty print. I practically need stg that does do the same but without opening up the file in an editor.

Br
0
Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
You need something to display it, so in essence you either have a text console -- not very useful --, or an editor. If the XML string does not contain many nodes, the console output might be ok.
One way is using PowerShell and the PowerShell Community Extensions (https://pscx.codeplex.com/), which import a format-xml cmdlet:
get-content c:\file.xml | format-xml

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
10 Tips to Protect Your Business from Ransomware

Did you know that ransomware is the most widespread, destructive malware in the world today? It accounts for 39% of all security breaches, with ransomware gangsters projected to make $11.5B in profits from online extortion by 2019.

jazzIIIloveAuthor Commented:
0
Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
If you prefer Java ...
0
jazzIIIloveAuthor Commented:
Hi,

Even i want to use, i don't know how to use Xalan.

Also, my xml is complex. Can i still use your solution?
0
Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
If your XML is complex, I cannot see why you are not wanting to use an editor like Notepad++ or MS XML Notepad. But you can still use a console output approach as my suggestion, it will just not be very informative ;-).
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
XML

From novice to tech pro — start learning today.