matching on part of node's attribute

Discussion in 'ASP .Net' started by =?Utf-8?B?Sm9l?=, Feb 2, 2006.

  1. 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
     
    =?Utf-8?B?Sm9l?=, Feb 2, 2006
    #1
    1. Advertising

  2. 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
     
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=, Feb 2, 2006
    #2
    1. Advertising

  3. 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
     
    =?Utf-8?B?Sm9l?=, Feb 3, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    1,643
  2. CB
    Replies:
    1
    Views:
    612
    Johannes Koch
    Oct 2, 2003
  3. Tjerk Wolterink
    Replies:
    2
    Views:
    1,504
    Dimitre Novatchev
    Aug 24, 2006
  4. clover2411
    Replies:
    4
    Views:
    983
    Andy Dingley
    Jan 23, 2007
  5. Replies:
    1
    Views:
    586
    Martin Honnen
    May 8, 2007
Loading...

Share This Page