[Expat-discuss] help for a program
William Park
opengeometry at yahoo.ca
Fri Feb 25 17:26:22 CET 2005
On Fri, Feb 25, 2005 at 12:51:25PM +0500, Muhammad Rizwan Khan wrote:
>
> Hello
>
> I am new to this library and XML. I want to write a program which 'll be
> given a xml packet (file) it 'll parse the packet and 'll return the
> values.
> Input to the program is as follows:
> <test>
> <one>
> <inner>stuff</inner>
> <inner>stuff1</inner>
> . . . </one>
> </test>
> output should be as:
> test
> one
> inner stuff
> inner stuff1
> ....
>
> Can you please guide me how i can do that, speically:
> inner stuff inner stuff1 ... stuff
If you want to do this in C, then you actually have to read the doc and
examples. (www.libexpat.org).
If you want to do this in shell, then use my patch to Bash
(http://freshmeat.net/projects/bashdiff/). Play around with
start () { # Usage: start tag att=value ...
echo
echo -n "$1"
}
data () { # Usage: data data
echo -n " $*"
}
xml -s start -d data '<test>...</test>'
If you're interested in data for <inner> tags only, then
data () {
case ${XML_ELEMENT_STACK[1]} in
inner) echo -n " $*" ;;
esac
}
--
William Park <opengeometry at yahoo.ca>, Toronto, Canada
Slackware Linux -- because I can type.
More information about the Expat-discuss
mailing list