(Video materials in preparation)
xb : XML beautifier
Usage : xb <xmlfile>
Version : Tue Jan 9 09:02:34 JST 2024
Edition : 1
Bad XML file, such as one with bad return code or bad alignment, is
beautified. "xb" also deletes blank record, puts one directory-tag
or file-tag or independent-tag on one line.
$ cat xml1
<?xml aaa="aaa"
bbb="bbb" ?>
<top/>
<!-- coment -->
<dir1 id1="0"
id2="1"><!-- comment --><dir2 id="a">
<!-- comment --><file attr="001">xxx</file><!-- comment -->
<file attr="002">yyy</file>
<file attr="003">zzz</file> </dir2>
<dir2 id="b"> <file attr="004">XXX</file> <file attr="005">YYY</file>
</dir2>
</dir1>
<tail/>
$ xb xml1
<?xml aaa="aaa" bbb="bbb" ?>
<top/>
<!-- coment -->
<dir1 id1="0" id2="1">
<!-- comment -->
<dir2 id="a">
<!-- comment -->
<file attr="001">xxx</file>
<!-- comment -->
<file attr="002">yyy</file>
<file attr="003">zzz</file>
</dir2>
<dir2 id="b">
<file attr="004">XXX</file>
<file attr="005">YYY</file>
</dir2>
</dir1>
<tail/>
End-tag immediately after start-tag is regarded as file-tag.
$ cat xml2
<dir><a></a></dir>
$ xb xml2
<dir>
<a></a>
</dir>
Independent-tag inbetween file-tags is regarded as a value of
file-tag.
$ cat xml3
<dir><a>abc<br/>def</a></dir>
$ xb xml3
<dir>
<a>abc<br/>def</a>
</dir>