xsl-list
[Top] [All Lists]

Re: Bash scritp

2005-03-08 08:59:47
Hi,

Maybe the XMLStarlet tool can help you here
(see http://xmlstar.sourceforge.net/). You can specify an
XPath expression on the command line, and it will get the
value for you.

So if you have the following document in ~/tmp/test.xml:

<foo>
   <date>today</date>
   <creator>me</creator>
</foo>

The following call to the XMLStarlet tool xml will give you the date:

   xml select -T -t -v '//date' ~/tmp/test.xml

Example in a bash script:

#!/bin/bash
FILE="$HOME/tmp/test.xml"
DATE=`xml select -T -t -v '//date' $FILE`
echo $DATE

This script will print the date for you ...

Hope this helps,

Menzo Windhouwer


Beatriz Langiano wrote:

Hi Hardy,


Thanks by your help, but what I need read some
specifics  elements of a XML document, as I do in
XSLT, for example:

<date>
<xsl:value-of select= "." />
</date>

<creator>
<xsl:value-of select= "." />
</date>


My script must read these elements values and insert
them in a database.

Thanks, Beatriz



--- Hardy Merrill <HMerrill(_at_)dhcr(_dot_)state(_dot_)ny(_dot_)us> wrote:
This is a bit (a lot) off topic for this list, but
I'll humor you since
I like Linux :)

I'll give this a shot, but please know that I
haven't done anything in
Linux and Bash in quite a while, so take this with a
grain of salt ;-)

Not sure if this is what you're looking for, but if
all you want to do
is "read" the XML document, I think(?) you could
pipe the XML file to
your bash script, and have the bash script read it
line by line from
standard input (STDIN).  I can't remember how to set
up the read loop in
bash, but it shouldn't be too hard to figure out.  I
think you could
probably find all you need by doing

   man bash

at a command prompt.

HTH.

Hardy Merrill

kevin(_dot_)rodgers(_at_)ihs(_dot_)com 03/08/05 10:25 AM >>>
Beatriz Langiano writes:
I was writing a bash script (in linux), and I'd
like
to  to read a XML document, like in XSLT.
Does somebody know how I could do this?
I haven't tried it, but William Park maintains a
souped-up version of
bash that includes XML support (nothing like
XPath/XSLT though):


http://freshmeat.net/projects/bashdiff/index.html#xml
http://home.eol.ca/~parkw/index.html#xml
--
Kevin Rodgers



--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/ or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to:
http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



Beatriz Langiano
Mestrado em Informática
Universidade Federal do Paraná - Brasil

__________________________________________________
Converse com seus amigos em tempo real com o Yahoo! Messenger http://br.download.yahoo.com/messenger/
--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--
Menzo Windhouwer, Centre for Mathematics and Computer Science (CWI)
Kruislaan 413, NL 1098 SJ Amsterdam, The Netherlands
url: http://www.cwi.nl/~windhouw/,  e-mail: windhouw(_at_)cwi(_dot_)nl


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>