As Dave says, xmllint is a useful utility for this. My script *Tidy up 
XML.sh* looks like this:
#!/bin/bash
#
# Tidy up an XML file

XMLLINT_INDENT=$'\t' xmllint --format - | \
sed -E 's/^([[:blank:]]*)(<[^<>]+>)(.*)(<[^<>]+>)$/\1\2\
\1'$'\t''\3\
\1\4/'
I added the *sed* command to insert some more line breaks in the XML for 
clarity, but you can choose to do without (by removing everything starting 
from the | pipe).


On Friday, June 16, 2017 at 2:21:29 PM UTC+2, Dave wrote:
>
> You should have a program called xmllint in your /usr/bin/ directory that 
> can parse and reformat an xml file, stream or URL. Since it can process 
> standard input and output to standard out, it can be used in a text filter. 
> See the user manual and 
> http://bbeditextras.org/wiki/index.php?title=Text_Filters for more 
> information on how to create and use text filters. See man xmllint or xmllint 
> --help for more about xmllint.
>
> On Thursday, June 15, 2017 at 10:01:51 AM UTC-4, Mike Margerum wrote:
>>
>> I used to be able to reformat / prettyify XML from BBEdit, but somewhere 
>> along the way this was removed.  It's probably one of the top things I need 
>> from the editor as I deal with a lot of XML.
>>
>> Is it back yet?  If so, how do you access it?  I see a format in the 
>> markup menu, but it looks like its only for HTML?
>>
>> Thanks
>>
>

-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or would like to report a problem, please email
"[email protected]" rather than posting to the group.
Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>
--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/bbedit.

Reply via email to