3 ms·
The idea is that those utilities work in the UNIX way, which means that they are line-oriented. The following two xml documents are equivalent: <a><b><c /
by p4bl0 13y ago
The idea is that those utilities work in the UNIX way, which means that they are line-oriented.
The following two xml documents are equivalent:
<a><b><c /></b><d>foo</d></a>
and
<a>
<b> <c /> </b>
<d>foo</d>
</a>
But to understand that using classical UNIX tools which are line-oriented is quite difficult, so you'll have a hard time doing operations such as "replace 'foo' by 'bar' if it appears as the textNode of a 'd' tag".
So the idea of hxpipe is that it is supposed to give you a line-oriented and similar representation of those two documents to work with.
But it actually fails to do that properly (at least for my taste). I largely prefer the output of xml2. Compare:
# first doc, output of hxpipe
(a
(b
|c
)b
(d
-foo
)d
)a
-\n
# second doc, output of hxpipe
(a
-\n
(b
-
|c
-
)b
-\n
(d
-foo
)d
-\n
)a
-\n
# output of xml2, for both documents
/a/b/c
/a/d=foo
- martijn_himself 13y agoMany thanks for the detailed reply. That makes a lot of sense.
- mzs 13y agoThanks! I've always created hokey awk scripts that split on <, but I really like that xml2 output!