Re: [xslt] Extracting just the value of a property
- From: Syd Bauman <Syd_Bauman Brown edu>
- To: The Gnome XSLT library mailing-list <xslt gnome org>
- Subject: Re: [xslt] Extracting just the value of a property
- Date: Tue, 26 Feb 2008 21:39:14 -0500
DS> <project name="FullDist" default="full">
DS> <property name="projectname" value="Bleeding_Edge"/>
DS> <!-- Lots of other stuff here -->
DS> </project>
DS> And you want to pull out just Bleeding_Edge without a lot of xml
DS> framing. From a shell script, ...
Where size, speed, and lots of repetitions are not a concern, I might
use the xmlstarlet package:
---------
#!/bin/bash
prop_value=$(xml sel -t \
-m "//project/property[ name='projectname']" \
-v '@value' /tmp/t.xml)
echo "I have '${prop_value}'."
---------
LQ> this XML design assumes that neither names nor properties ever
LQ> contain markup themselves, and are always in the same language.
DS> Sorry, which XML design?
I believe Liam meant the design of your data, i.e. the first 4 lines
of the body of this e-mail. He was pointing out the disadvantages of
putting data into attributes of empty elements, rather than using
child elements. Re-read his example, it's a good one. (Except that
<sup> only indicates a superscript, not that the speed of light is
squared. :-)
LQ> I wrote a simple C program that takes an XML document and an
LQ> XPath expression, and returns the result. You're welcome to a
LQ> copy.
I'd love to see this, too, Liam.
DV> [... xmlTextReader ...]
Wow!
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]