in reply to Indent XML data
I'm sure someone's going to pipe up with one of the XML::* modules that I don't recall offhand but you could use xmllint (which most expat or xmllib installs should come with) and it's --format option to get at least started.
$ xmllint --format --pretty 1 sample_txt.xml <?xml version="1.0" encoding="ISO-8859-1"?> <root> <para> <pnum>1</pnum> <ptext>This is a sample of a very specific text <emph>called</emph +> <term>description</term> which has 2 subtypes: <list><item><term>1. +</term><p>precise</p></item><item><term>2.</term><p>fuzzy</p></item>< +/list></ptext> </para> </root>
The cake is a lie.
The cake is a lie.
The cake is a lie.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Indent XML data
by LexPl (Beadle) on Jan 22, 2025 at 16:43 UTC |