Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > matching on part of node's attribute

Reply
Thread Tools

matching on part of node's attribute

 
 
=?Utf-8?B?Sm9l?=
Guest
Posts: n/a
 
      02-02-2006
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
 
Reply With Quote
 
 
 
 
=?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
Guest
Posts: n/a
 
      02-02-2006
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

 
Reply With Quote
 
 
 
 
=?Utf-8?B?Sm9l?=
Guest
Posts: n/a
 
      02-03-2006
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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with Pattern matching. Matching multiple lines from while reading from a file. Bobby Chamness Perl Misc 2 05-03-2007 06:02 PM
Compare 2 files and put the matching part in a 3rd file BerNaC Perl Misc 9 02-16-2005 03:35 PM
Matching a part of a string TonyShirt Perl Misc 4 07-02-2004 06:23 PM
Matching attribute names to element names in a different path Carl XML 0 04-01-2004 01:15 PM
Pattern matching : not matching problem Marc Bissonnette Perl Misc 9 01-13-2004 05:52 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57