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

matching on part of node's attribute

Joe
Hello All:

I have an xml document that contains <Control> nodes, each of which has a
"name" attribute (i.e. <Control name="myControl" />. I want to find all of
the nodes that have "Recipient" anywhere in the name attribute's value. So,
if I have the following:

<Controls>
<Control name="PrimaryRecipient" />
<Control name="RecipientCC1" />
<Control name="RecipientCC2" />
<Control name="RecipientCC3" />
<Control name="Claimant" />
</Controls>

when i request all of the nodes with 'Recipient' in the name attribute, I
want to get back a nodelist of the first four Control nodes.

I've poked around and have tried to devise a way to use the fn:contains
function from XPath, but am totally stuck. Do any of you know how to do
this? Should I be using something from the System.Xml.XPath namespace
instead?

I'm in over my head. Any help will be much appreciated.

TIA,
--
Joe
Feb 2 '06 #1
2 925
authors/author/publisher/book[contains(@name, 'ADO')]

Controls/Control[contains(@name,'Recipient')]

you can also use starts-with where appropriate.

Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Joe" wrote:
Hello All:

I have an xml document that contains <Control> nodes, each of which has a
"name" attribute (i.e. <Control name="myControl" />. I want to find all of
the nodes that have "Recipient" anywhere in the name attribute's value. So,
if I have the following:

<Controls>
<Control name="PrimaryRecipient" />
<Control name="RecipientCC1" />
<Control name="RecipientCC2" />
<Control name="RecipientCC3" />
<Control name="Claimant" />
</Controls>

when i request all of the nodes with 'Recipient' in the name attribute, I
want to get back a nodelist of the first four Control nodes.

I've poked around and have tried to devise a way to use the fn:contains
function from XPath, but am totally stuck. Do any of you know how to do
this? Should I be using something from the System.Xml.XPath namespace
instead?

I'm in over my head. Any help will be much appreciated.

TIA,
--
Joe

Feb 2 '06 #2
Joe
Peter,

Thanks. This did it.

--
Joe
"Peter Bromberg [C# MVP]" wrote:
authors/author/publisher/book[contains(@name, 'ADO')]

Controls/Control[contains(@name,'Recipient')]

you can also use starts-with where appropriate.

Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Joe" wrote:
Hello All:

I have an xml document that contains <Control> nodes, each of which has a
"name" attribute (i.e. <Control name="myControl" />. I want to find all of
the nodes that have "Recipient" anywhere in the name attribute's value. So,
if I have the following:

<Controls>
<Control name="PrimaryRecipient" />
<Control name="RecipientCC1" />
<Control name="RecipientCC2" />
<Control name="RecipientCC3" />
<Control name="Claimant" />
</Controls>

when i request all of the nodes with 'Recipient' in the name attribute, I
want to get back a nodelist of the first four Control nodes.

I've poked around and have tried to devise a way to use the fn:contains
function from XPath, but am totally stuck. Do any of you know how to do
this? Should I be using something from the System.Xml.XPath namespace
instead?

I'm in over my head. Any help will be much appreciated.

TIA,
--
Joe

Feb 3 '06 #3

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

Similar topics

2
by: ahogue at theory dot lcs dot mit dot edu | last post by:
Hello - Is there any way to match complex subtree patterns with XPath? The functions I see all seem to match along a single path from root to leaf. I would like to match full subtrees. For...
4
by: David S. Alexander | last post by:
I am trying to transform XML to XML using an XSLT in C#, but the root node of my XML is not being matched by the XSLT if it has an xmlns attribute. Am I handling my namespaces incorrectly? My C#...
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: 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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.