Re: tdom xpath search
From: Rolf Ade (pointsman_at_gmx.net)
Date: 03/17/05
- Next message: 04642920123-0001_at_t-online.de: "Re: catch command"
- Previous message: Bryan Oakley: "Re: Image hotspots in Tcl"
- In reply to: Jeannot: "tdom xpath search"
- Next in thread: Jeannot: "Re: tdom xpath search"
- Reply: Jeannot: "Re: tdom xpath search"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 17 Mar 2005 13:00:25 +0000 (UTC)
In article <d1bcr4$mt1$1@news.u-strasbg.fr>,
Jeannot <jean.muller@igbmc.u-strasbg.fr> wrote:
>I am actually working on XML files and I use tdom as a handler of xml. I
> have a question concerning xpath expression. I need to search all
>nodes (sequence) which child (seq-name) contains a certain string:
>
>So I try this "/MSA/alignment/sequence\[string(seq-name)='toto'\]" which
>help me to find the node that exactly match toto and now I need to find
>'toto_*' and so I try this
>:"/MSA/alignment/sequence\[string(seq-name)='toto_*'\]" and it does not
>work like this !!!
Sure. This query simply does not, what you intend; XPath 1.0 doesn't
know string matching wild-cards. For your case, you could use the
XPath function starts-with():
/MSA/alignment/sequence[starts-with(seq-name,'toto_')]
A few notes:
You didn't need 'string(seq-name)'. If the the context of the
expression requires a string, the selected node-set will automatically
be converted to a string value, exactly as string() does it.
This expression will only do what you (probably) want, if there is
always only maximum one seq-name child below sequence or if it's
always the first seq-name child below sequence, which is relevant. If
you have sequence nodes with more than one seq-name childs and you
want to select all sequence with at least one seq-name with a text
content, which starts with 'toto_' you'll need another query like:
/MSA/alignment/sequence[seq-name[starts-with(.,'toto_')]]
Your question is not tcl or tdom related, but an XPath language
question. Asking such questions at a related place, as the xslt
mailing list (http://www.mulberrytech.com/xsl/xsl-list/) may get you
faster/better answers than asking this at c.l.t.
rolf
- Next message: 04642920123-0001_at_t-online.de: "Re: catch command"
- Previous message: Bryan Oakley: "Re: Image hotspots in Tcl"
- In reply to: Jeannot: "tdom xpath search"
- Next in thread: Jeannot: "Re: tdom xpath search"
- Reply: Jeannot: "Re: tdom xpath search"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|