473,414 Members | 1,626 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,414 software developers and data experts.

Using XPath to build a Breadcrumb menu.

Hi,

I'm a complete newbie to XML and am needing to rush through a job requiring
far more knowledge than I have the time to gather.

Basically... I need to build a breadcrumb menu for our website, using a
passed URL and an XML menu string, what has been retrieved from an SQL server
(we need to support no-script clients, hence the use of the request URL).

Essentially I need to do the following::

- Search the XML string to find nodes where an attribute contains the
absolutepath of the passed URL.
eg PassedURL = "http://www.mysite.com/Default.aspx?dept=main&info=new"
AbsolutePath="/Default.aspx"
Find nodes like <item href="/Default.aspx?dept=main&content=old" />

- Do a test on the full attribute value to see if it's the one I'm really
looking for.
eg Compare the passed querystring args to the attribute's args (they
might not be in the same order, so I need to test the args individually).

- If it is the one I'm looking for, then gather up it and all it's
ancestors, to build a breadcrumb menu

- If it's not... search for the next node.

Being a menu, the structure is multi-level, and <item href="value" /> nodes
can appear at all levels... and I have no way of knowing how they got
there... I need to search the menu, find the entry for the node they chose,
and then back-track to build up the href items of all the ancestor nodes.

So far, I've worked out that I need to be using XPath, and have worked out
how to get the XML string into an XPathDocument

XPathDocument xml_PathDoc = new XPathDocument(new StringReader((string)
xml_String));

and then I THINK that I need to use an Navigator like this...

XPathNavigator xmlPathNav = xml_PathDoc.CreateNavigator();

The test part I'm obvioulsy OK with... that's just simple string work... but
the search, find and then gather ancestors... I'm totally lost.

It's taken me a day to get this far... and I have people screaming at me to
get the thing working.

Much appreciate any assistance, hints or links thrown my way.

Cheers,

-- Mike.
Jan 19 '06 #1
1 1888
Never Mind... I've worked it all out and having it running now.

Cheers.

"Mike" wrote:
Hi,

I'm a complete newbie to XML and am needing to rush through a job requiring
far more knowledge than I have the time to gather.

Basically... I need to build a breadcrumb menu for our website, using a
passed URL and an XML menu string, what has been retrieved from an SQL server
(we need to support no-script clients, hence the use of the request URL).

Essentially I need to do the following::

- Search the XML string to find nodes where an attribute contains the
absolutepath of the passed URL.
eg PassedURL = "http://www.mysite.com/Default.aspx?dept=main&info=new"
AbsolutePath="/Default.aspx"
Find nodes like <item href="/Default.aspx?dept=main&content=old" />

- Do a test on the full attribute value to see if it's the one I'm really
looking for.
eg Compare the passed querystring args to the attribute's args (they
might not be in the same order, so I need to test the args individually).

- If it is the one I'm looking for, then gather up it and all it's
ancestors, to build a breadcrumb menu

- If it's not... search for the next node.

Being a menu, the structure is multi-level, and <item href="value" /> nodes
can appear at all levels... and I have no way of knowing how they got
there... I need to search the menu, find the entry for the node they chose,
and then back-track to build up the href items of all the ancestor nodes.

So far, I've worked out that I need to be using XPath, and have worked out
how to get the XML string into an XPathDocument

XPathDocument xml_PathDoc = new XPathDocument(new StringReader((string)
xml_String));

and then I THINK that I need to use an Navigator like this...

XPathNavigator xmlPathNav = xml_PathDoc.CreateNavigator();

The test part I'm obvioulsy OK with... that's just simple string work... but
the search, find and then gather ancestors... I'm totally lost.

It's taken me a day to get this far... and I have people screaming at me to
get the thing working.

Much appreciate any assistance, hints or links thrown my way.

Cheers,

-- Mike.

Jan 20 '06 #2

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

Similar topics

2
by: Eric | last post by:
I am looking for a breadcrumb class in PHP that does not rely on the directory structure to build the trail. I have been using Richard Baskettes - http://www.baskettcase.com/classes/breadcrumb/...
7
by: johkar | last post by:
I am confused on childNodes or children. When you have nested lists, I would think it would all be one list in the Dom, this doesn't seem to be the case. So how do you traverse an unordered list?...
2
by: Felicity | last post by:
Hello, The following XML file shows an example of some config data for a Side Button Bar control. There are two forms this Button Bar control relates to, "frmMainMenu" and "Listing". <?xml...
2
by: Felicity | last post by:
Hello, Using the following XML file, I would like to be able to filter using an XPath to the nodes where Menu = Yes and Form Name = frmMainMenu <?xml version="1.0" standalone="yes"?>...
1
by: TG | last post by:
I would like to know how to create a breadcrumb trail or menue in ASP.NET/VB.NET. Could someone please help me with this? Thank you. TG
6
by: dotnetnoob | last post by:
i would like to know how i can build xpath expression dynamiclly. let's say i have a following xml file: <EventEnrollment InstanceNumber = "675"> <EventSource> <ObjectReference...
3
by: Brian | last post by:
Using external XML, I'm trying to build a quiz, but I can't seem to specify the DataSource for the RadioButtonList within a Repeater ItemTemplate. I've tried a number of approaches, but I haven't...
0
by: Boris Twila | last post by:
How de do? My menu and breadcrumb trail use the sitemap file. I have things in my sitemap that I want to show up in my breadcrumb trail, but not in my menu. How to do?
8
by: =?Utf-8?B?Q2hyaXMgSGFsY3Jvdw==?= | last post by:
Hi there I've successfully added some .NET validation controls to a page (using <asp:RequiredFieldValidator ...), however when I try to set the 'display' property to 'dynamic', my page then...
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.