(Video materials in preparation)
xmldir : Convert from XML file to Field file by specifying XML path
Usage : xmldir /<DirTag1>/<DirTag2>/.../<DirTagN> <xmlfile>
Option : -c<n>
Version : Tue Jan 9 09:02:34 JST 2024
Edition : 1
"xmldir" command outputs XML path and all subtree with name and
attribute and value by each end XML tag.
"-c" option adds data field of index number of designated XML path.
N hierachial paths means N indexes and when the same tag repeats on
the same hierachy, index number is incremented. When parent tag is
repeated, lower indexes are reset to 1.
"-c<n>" options give 0 head filling to index number with <n>digit.
Input file must be beautified by "xb" command in advance.
$ cat xml
<dir1 id="A">
<dir2 id="B">
<day>23/Jul.2015</day>
<day>24/Jul.2015</day>
</dir2>
<dir2 id="C">
<day>25/Jul.2015</day>
<day>26/Jul.2015</day>
</dir2>
</dir1>
$ xmldir /dir1/dir2 xml
dir1 id A dir2 id B day 23/Jul.2015
dir1 id A dir2 id B day 24/Jul.2015
dir1 id A dir2 id C day 25/Jul.2015
dir1 id A dir2 id C day 26/Jul.2015
$ xmldir -c3 /dir1/dir2 xml
001 001 dir1 id A dir2 id B day 23/Jul.2015
001 001 dir1 id A dir2 id B day 24/Jul.2015
001 002 dir1 id A dir2 id C day 25/Jul.2015
001 002 dir1 id A dir2 id C day 26/Jul.2015
$ cat xml
<dir1>
<dir2 id="0">
<attributes>
<dir4 id="X">
<header1>xxxx</header1>
<header2>yyyy</header2>
</dir4>
</attributes>
</dir2>
<dir2 id="1">
<attributes>
<data>a</data>
<data>b</data>
</attributes>
<attributes>
<data>c</data>
</attributes>
</dir2>
</dir1>
<dir1>
<dir2 id="2">
<attributes>
<data>d</data>
</attributes>
<attributes>
<data>e</data>
</attributes>
<attributes>
<data>f</data>
</attributes>
</dir2>
</dir1>
$ xmldir -c3 /dir1/dir2/attributes xml
001 001 001 dir1 dir2 id 0 attributes dir4 header1 xxxx
001 001 001 dir1 dir2 id 0 attributes dir4 header2 yyyy
001 002 001 dir1 dir2 id 1 attributes data a
001 002 001 dir1 dir2 id 1 attributes data b
001 002 002 dir1 dir2 id 1 attributes data c
002 001 001 dir1 dir2 id 2 attributes data d
002 001 002 dir1 dir2 id 2 attributes data e
002 001 003 dir1 dir2 id 2 attributes data f