473,395 Members | 1,678 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Why isn't my xpathNavigator selecting what I want?

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?
Nov 18 '05 #1
2 1186
> <?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
Nov 18 '05 #2
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?
Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Craig Pearson | last post by:
Hi My function receives an XPathNavigator object. From here I need to build a DataSet to load into SQL Server (using SQLXML adaptor). Does anyone have an idea on the most efficient way to...
7
by: David Thielen | last post by:
Hi; Is there a way from an XPathNavigator object to get an xpath string that will, when used in a Select(xpath) on the underlying base/root XPathNavigator return the same XPathNavigator? In...
6
by: David Thielen | last post by:
Hi; How can I tell if I can call XPathNavigator.ValueAsBoolean safely - without throwing an exception. I want to take one course of action if the value can be interpreted as a boolean. But I...
2
by: JSheble | last post by:
I'm integrating with a customer application, and in their assembly, when I call a method it returns data to us as an XPathNavigator object. I can parse the various elements I need out of this...
4
by: Jack Fox | last post by:
I'm navigating through a XPathDocument consisting of mostly mixed complex type elements (i.e. innertext plus more elements). When I use XPathNavigator.Value to retrieve the text I get everything...
11
by: ericms | last post by:
Can anybody show me how to insert a CDATA section using XPathNavigator ? I have tried the follwing with no luck: XmlDocument docNav = new XmlDocument(); docNav.LoadXml(xmlString);...
4
by: Bruce Sandeman | last post by:
Hi, Does anyone know how to serialize an XPathNavigator object? I have tried the following but it moans that the xpn does not have a parameterless constructor. XPathNavigator xpn =...
2
by: =?Utf-8?B?Tm9yZW1hYw==?= | last post by:
Hi. Using VS2005, .NET 2.0. I have an xml document that I want to go through and set the values on attributes of elements. The elements are complex types defined in my schema (xsd) files. ...
5
by: Gigs_ | last post by:
hi i have xml in this structue <?xml version="1.0" encoding="utf-8" ?> <obrazac sifra="N-08-V"> <!-- Stanje: u obradi Primjedbe: nema -->
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.