473,386 Members | 1,785 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,386 software developers and data experts.

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.

Feb 9 '06 #1
2 2680


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/
Feb 9 '06 #2
By jove, it works!

Thanks,

Duncan.

Feb 9 '06 #3

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

Similar topics

2
by: RanDeep | last post by:
I have two nodes that both exist underneath the root node. They are linked, however, in the sense that one of the nodes contains a copy of an id that is used to refer to the other. However, when I...
2
by: serge calderara | last post by:
Dear all, I am populating a treeview control with an XML file. I need to skip duplicate node entry from XML file in treeview if exit For that I ma using the following line of code : If...
3
by: Earl Teigrob | last post by:
I am considering writing a Class that Selects, Adds, Updates and Deletes Nodes in an XML File but do not what to reinvent the wheel. (See XML file below) That data format would emulate records...
0
by: usamaalam | last post by:
Hello everybody, I have a treeview control in my application and a hierarchy of sub-nodes. Application works on rights. If user doesnt have rights to see a particular screen, the treeview node...
2
by: K B | last post by:
I bit new to this. My xml files contains the following nodes: <root> <WI Title="Test1"> <Role Name="Legal"/> <Role Name="PM"/> </WI> <WI Title="Test1"> <Role Name="Legal"/> <Role...
3
by: thrill5 | last post by:
I have an xml document such as: <device> <element>first</element> <element>second</element> </device> I am using this as the source for an xslt transform that goes like <xsl:for-each...
16
by: Brian D | last post by:
I have a multiple select list that is created dynamically based on a previous selection on an asp page. The first thing I do is to clear the curent option list by ...
1
by: Andy | last post by:
Hi, Does anyone know why when I hardcode a literal to filter a subset of nodes by a particular attribute value, my template processes the correct subset. But, when I use a variable that is set...
4
by: Dmitry Kulinich | last post by:
Guys! Is there are any possibility to create nodes with duplicate names and different types in XSD? I've read the whole specification and tried in a many different ways, but not successfull. ...
5
by: AdrianGawrys | last post by:
Hi Guys, I have an xml similar to this one: <?xml version="1.0" encoding="UTF-8"?> <SystemUpdate ForceUpdate="false" > <A ForceUpdate="false"> <Book name="Black" /> <Book...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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.