Seek xpath expression where an attribute name is a regular expression

G

GIMME

For starters ....

If :

//input[@name='start_date']

is the xpath syntax to see if an element with an attribute
named start_date exists ...

Then what is the xpath syntax to return elements having
an attribute named '*date*' .

That is there a way to turn start_date into a regular expression?

Thanks!
 
M

Martin Honnen

GIMME said:
For starters ....

If :

//input[@name='start_date']

is the xpath syntax to see if an element with an attribute
named start_date exists ...

No, that expression looks for <input> elements at all levels that have
an attribute named 'name' that has the value 'start_date'.
You will be able to look for for elements with an attribute named
'start_date' with the XPath expression
//input[@start_date]
Then what is the xpath syntax to return elements having
an attribute named '*date*' .

That is there a way to turn start_date into a regular expression?

XPath 1.0 doesn't support any regular expressions, there are however
some string functions like contains so could try
//input[contains(local-name(@*), 'date')]
with the example XML being

<?xml version="1.0" encoding="UTF-8"?>
<root>
<input date="2004-01-01" />
<input start_date="2004-01-01" />
<input date_final="2004-10-10" />
<input att="Kibology" />
<input />
</root>

the above XPath selects

<input date="2004-01-01" />
<input start_date="2004-01-01" />
<input date_final="2004-10-10" />
 
Joined
Dec 29, 2008
Messages
1
Reaction score
0
how to check values with some regular expression

if i'm having some attributes value like email and i want an xpath with regular expression to check the value?

how this can be done
 

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,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top