I'm a in a little over my head in XMl syntax and ASP.net xpathnavigator methods.
I need to figure out how to grab the text of a specific node in an xml
file based on one of this particular nodes descendants.
Here's some of the sample XML:
<?xml version="1.0"?>
<!--Created on 10/16/2004 8:05:57 PM-->
<menuItems>
<menuItem>
<pageID>1</pageID>
<pageName>Home</pageName>
<menuCategory />
</menuItem>
<menuItem>
<pageID>2</pageID>
<pageName>Tax and Accounting</pageName>
<menuCategory>tax</menuCategory>
<menuItem>
<pageID>3</pageID>
<pageName>Services and Rates</pageName>
<menuCategory />
</menuItem>
So, for example, let's say the current page is '3'. I want to dive
into this XML file, look for the menuItem who has pageID of 3, and
then find the first ancestor-or-self that also hase a menuCategory
that contains a value. If there is a value, read it.
Initially, I was just using an xpathnavigator and an apath call, but
then realized I also need to use some logic, since I need to read each
menuCategory to first see if it has a value (since I'm only assigning
an actual value to the root level items.
My question is to ask if someone can provide sample ASP.net code to
get me there (I'm using vb.net)
I think I need to use an xpathnavigator to first grab the child node,
and then apathiterator, to iterate up the tree looking for the first
menucategory that has a stored value, and then grab it.
(This is my first question, so if my price is out of line, please let me know!)
Also, I can post my current sample code if that is of value. |