Why isn't my xpathNavigator selecting what I want?

D

Darrel

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?
 
D

Darrel

<!--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
 
D

Darrel

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?
 

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

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,527
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top