![]() |
Select nodes where an attribute contains some sub-text
Can I use the contains() function within an xpath query to return a
node whose attribute contains some text? Something like: selectNodes("//Dataset[@Pattern contains(@Pattern, 'xyz')] so for the given xml doc <root> <Datasets> <Dataset name="dataset1" Pattern="abc" AnotherAttribute="xyz"/> <Dataset name="dataset2" Pattern="xyz" AnotherAttribute="xyz"/> <Dataset name="dataset3" Pattern="vwxyz"/> </Datasets> </root> The nodes dataset2 and dataset3 would be returned because their 'Pattern' attribute contains the text 'xyz'. Many thanks, Duncan. |
Re: Select nodes where an attribute contains some sub-text
Duncan wrote: > Can I use the contains() function within an xpath query to return a > node whose attribute contains some text? Yes. > Something like: selectNodes("//Dataset[@Pattern contains(@Pattern, > 'xyz')] That is syntactically wrong. A possible XPath expression could be /root/Datasets/Dataset[contains(@Pattern, 'xyz')] -- Martin Honnen http://JavaScript.FAQTs.com/ |
Re: Select nodes where an attribute contains some sub-text
By jove, it works!
Thanks, Duncan. |
| All times are GMT. The time now is 08:44 AM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.