matching on part of node's attribute

G

Guest

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,
 
G

Guest

authors/author/publisher/book[contains(@name, 'ADO')]

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

you can also use starts-with where appropriate.

Peter
 
G

Guest

Peter,

Thanks. This did it.

--
Joe


Peter Bromberg said:
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 said:
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,
 

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

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top