XML + Bash
William Park
opengeometry-FFYn/CNdgSA at public.gmane.org
Tue Aug 17 18:51:03 UTC 2004
Hi all,
After looking at Expat XML parser (www.libexpat.org), I've decided to
patch a simple interface to Bash shell. Mainly, so that Gawk can't brag
about it having an interface. :-)
In C code, you would register callback functions, and Expat will call
them as it encounters various XML components. So, I made it similar in
shell. That is, you specify shell functions/commands to be called. You
still have to do some bookkeeping, but I think it's easier in shell. Of
course, you can do other things in C which you can't do in shell.
Ref:
http://freshmeat.net/projects/bashdiff/ -- general link
or
http://home.eol.ca/~parkw/index.html#xml -- XML specific
help xml
For example,
xml -s echo "<tag a='11'>text</tag>" --> tag a 11
where
'-s' -- registers 'echo' as callback function, and it will be
called with element tag and its attribute names/values on
command-line, ie.
echo 'tag' 'a' '11'
At the moment, there are 7 callbacks you can specify:
- element start/end,
- character data
- processing instruction
- comment
- namespace start/end
Any feedback about userability or usage problem are most appreciated.
Enjoy!
--
William Park <opengeometry-FFYn/CNdgSA at public.gmane.org>
Open Geometry Consulting, Toronto, Canada
--
The Toronto Linux Users Group. Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml
More information about the Legacy
mailing list