XPath : comparing a value that starts with a prefix

Xuejun Li (SH RDC )

Usenet Archive
Joined
Feb 19, 2004
Messages
3
Reaction score
0
Hi,
How do I select a value that starts with a certain prefix? For example I want all <author> elements that contain a <last-name> element with a value that begins with the letter Mi. Will this work? Or it will also match "Ni"? author[last-name &gt; "Mi"] A more general question, how do a match against a regular expression? Thanks Li Xuejun
 

Martin Honnen

Usenet Archive
Joined
Apr 8, 2000
Messages
6,174
Reaction score
0
Xuejun said:
How do I select a value that starts with a certain prefix? For example I want all <author> elements that contain a <last-name> element with a value that begins with the letter Mi. Will this work? Or it will also match "Ni"?
author[last-name &gt; "Mi"]

There are string functions in XPath 1.0,
author[starts-with(last-name, 'Mi')]
A more general question, how do a match against a regular expression?

XPath 1.0 has no support for regular expressions matching, with XPath
2.0 there will probably support for that, at least the current working draft has some functions like matches which takes a string to match against a string interpreted as a regular expression pattern.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
548,042
Messages
3,104,224
Members
248,132
Latest member
henrywalsh

Latest Threads

Top