XPath : comparing a value that starts with a prefix

  • Thread starter Xuejun Li \(SH/RDC\)
  • Start date
X

Xuejun Li \(SH/RDC\)

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
 
M

Martin Honnen

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
473,995
Messages
2,570,236
Members
46,821
Latest member
AleidaSchi

Latest Threads

Top