Why isn't my xpathNavigator selecting what I want?

Discussion in 'ASP .Net' started by Darrel, Oct 24, 2004.

  1. Darrel

    Darrel Guest

    I think I am in syntax hell. ;o)

    Here's some XML that I'm trying to grab some text from:

    <?xml version="1.0"?>
    <!--Created on 10/16/2004 8:05:57 PM-->
    <menuItems>
    <menuItem>
    <pageID>2</pageID>
    <pageName>Tax and Accounting</pageName>
    <menuCategory>tax</menuCategory>
    <menuItem>
    <pageID>3</pageID>
    <pageName>Services and Rates</pageName>
    <menuCategory />
    </menuItem>

    What I want to do is select the menuCategory text of any parent of the
    menuItem who's pageID is set to specific variable.

    So, if I pass a pageID of '3' to the above, I want to look up all of it's
    parents until I find one with a menuCategory set to a value other than
    empty.

    I thought I could just use an expression, but now realize that I probably
    need to use an iterator to grab and entire node, check the first
    menuCategory for a value, if empty, navigate up, check again, and repeat
    until I get a value.

    Does that sound like the right direction?
     
    Darrel, Oct 24, 2004
    #1
    1. Advertising

  2. Darrel

    Darrel Guest

    > <?xml version="1.0"?>
    > <!--Created on 10/16/2004 8:05:57 PM-->
    > <menuItems>
    > <menuItem>
    > <pageID>2</pageID>
    > <pageName>Tax and Accounting</pageName>
    > <menuCategory>tax</menuCategory>
    > <menuItem>
    > <pageID>3</pageID>
    > <pageName>Services and Rates</pageName>
    > <menuCategory />
    > </menuItem>


    Further clarification. I think I figured out how to grab the value without
    the need of the iterator. This:

    //menuCategory[../descendant-or-self::pageID = '3']

    works just fine in an XSL file...it returns exactly what I need.

    However, I'm not sure how to turn that select into a STRING in my asp.net
    code:

    dim strtest as string

    strtest = xpn.Select("//menuCategory[../descendant-or-self::pageID = '3']")
    I can't do the above, because I can't convert the apathnavigator select into
    a string. What's the path I need to take to turn that into a text string?

    -Darrel
     
    Darrel, Oct 24, 2004
    #2
    1. Advertising

  3. Darrel

    Darrel Guest

    Actually, let me simplify my entire question:

    How do I go from an axpathnavigator selected item to a string?

    I'd like to do this:

    xpathnavigator.select(my statement).tostring

    However, I can't convert a xpathnavigator.select to a string. I'm guessing
    I'm missing some in-between logic here?
     
    Darrel, Oct 24, 2004
    #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. Philip Townsend

    XPathNavigator oddities

    Philip Townsend, Dec 5, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    328
    Philip Townsend
    Dec 5, 2003
  2. DN
    Replies:
    2
    Views:
    11,834
  3. Mr. SweatyFinger
    Replies:
    2
    Views:
    2,131
    Smokey Grindel
    Dec 2, 2006
  4. darrel
    Replies:
    4
    Views:
    369
    darrel
    Aug 17, 2007
  5. laredotornado

    Why isn't invoking "click" doing what I want?

    laredotornado, Jan 16, 2009, in forum: Javascript
    Replies:
    1
    Views:
    73
    Erwin Moller
    Jan 16, 2009
Loading...

Share This Page