473,385 Members | 1,597 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Seek xpath expression where an attribute name is a regular expression

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!
Jul 20 '05 #1
2 7353


GIMME wrote:
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" />
--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #2
Thanks Martin.

This is very helpful.
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Anna | last post by:
Hi all. I hav eproblems constructing one XPath expression. Here is what I want to do: I want to choose all area tags that belong to a certain image map, having src of the image map. I don't want...
9
by: Iain | last post by:
I want to create an XML configuration file which might look like <REGION Name="Europe" WingDing="Blue"> <COUNTRY Name="UK" WingDing="white"> <TOWN Name="London" WingDing="Orange" /> </COUNTRY>...
7
by: Sebastian Petzelberger | last post by:
Hi group, please give me an example of a xpath with regex or better a link with examples. Thanks in advance, Sebastian
1
by: Xuejun Li \(SH/RDC\) | last post by:
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...
1
by: Marek Mänd | last post by:
<style> .marek{} </style> etc.. <root> <element class="marek mand"/> <element class="mand marek blah"/> <element class="mand marekmänd"/> <element class="mand marekk"/> </root>
5
by: Gnic | last post by:
Hi , I have an XmlDocument instance, I want to find a node in the xml, but I don't know it's path until runtime, for example <aaa> <bbb name="x"/> <aaa attr="y"> <ccc>sometext</ccc> </aaa>
3
by: SD | last post by:
Hi, How can i get all the nodes with attribute Name = "Publisher" or Name="Administrator" using XPath query and C# for this xml doc? <GetRoleCollectionFromUser...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.