473,511 Members | 9,983 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

xpath expression

Hello,

I am trying to use an XPath to select siteMapNode nodes where
footer=true.
What I have is:
siteMapNode[@footer='true']

It is not working.
My XML document is:

<?xml version="1.0" encoding="utf-8" ?>
<siteMap
xmlns = "http://schemas.microsoft.com/ASPNet/SiteMap-File-1.0" >
<siteMapNode>
<siteMapNode
url = "~/Default.aspx"
title = "Home"
description = "Desc1"
footer = "true" />
<siteMapNode
url = "~/Contacts.ASPx"
title = "Contactos"
description = "Desc2"
footer = "true" />
</siteMapNode>
</siteMap>

Could someone help me out?

Thanks,
Miguel

Nov 10 '06 #1
4 1726
shapper wrote:
I am trying to use an XPath to select siteMapNode nodes where
footer=true.
What I have is:
siteMapNode[@footer='true']
<siteMap
xmlns = "http://schemas.microsoft.com/ASPNet/SiteMap-File-1.0" >
You have a default namespace declaration here meaning the elements are
in the namespace with URL
http://schemas.microsoft.com/ASPNet/SiteMap-File-1.0.

See <http://www.faqts.com/knowledge_base/view.phtml/aid/34022/fid/616>
for a solution.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Nov 10 '06 #2
In article <11**********************@f16g2000cwb.googlegroups .com>,
shapper <md*****@gmail.comwrote:
>I am trying to use an XPath to select siteMapNode nodes where
footer=true.
What I have is:
siteMapNode[@footer='true']
><siteMap
xmlns = "http://schemas.microsoft.com/ASPNet/SiteMap-File-1.0" >
<siteMapNode>
<siteMapNode
url = "~/Default.aspx"
title = "Home"
description = "Desc1"
footer = "true" />
Your <siteMapNodeelements are in the

http://schemas.microsoft.com/ASPNet/SiteMap-File-1.0

namespace, so you have to do the same for your XPaths. XPath doesn't
use the default namespace so you'll have to declare a prefix and use
that, e.g.

sm:siteMapNode[@footer='true']

You haven't said what program you're using with these XPaths, so I
can't tell you how to declare the prefix. If it is in an XSLT
stylesheet, you can just declare it on the <xsl:stylesheetelement.
If you calling some XPath library, it will have a way to do it.

-- Richard

--
"Consideration shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
Nov 10 '06 #3
Hello,

I am using VB.Net / Asp.Net to access my XML file.
The XPath is in my VB.Net code.

Thanks,
Miguel

Richard Tobin wrote:
In article <11**********************@f16g2000cwb.googlegroups .com>,
shapper <md*****@gmail.comwrote:
I am trying to use an XPath to select siteMapNode nodes where
footer=true.
What I have is:
siteMapNode[@footer='true']
<siteMap
xmlns = "http://schemas.microsoft.com/ASPNet/SiteMap-File-1.0" >
<siteMapNode>
<siteMapNode
url = "~/Default.aspx"
title = "Home"
description = "Desc1"
footer = "true" />

Your <siteMapNodeelements are in the

http://schemas.microsoft.com/ASPNet/SiteMap-File-1.0

namespace, so you have to do the same for your XPaths. XPath doesn't
use the default namespace so you'll have to declare a prefix and use
that, e.g.

sm:siteMapNode[@footer='true']

You haven't said what program you're using with these XPaths, so I
can't tell you how to declare the prefix. If it is in an XSLT
stylesheet, you can just declare it on the <xsl:stylesheetelement.
If you calling some XPath library, it will have a way to do it.

-- Richard

--
"Consideration shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
Nov 10 '06 #4
shapper wrote:
I am using VB.Net / Asp.Net to access my XML file.
The XPath is in my VB.Net code.
You'll have to look at the documentation for your XPath API to find out
how to tell it what the namespace bindings are. I don't go near VB or
..Net so I can't give you more specific advice.

XPaths are namespace-aware. You have to work with that.

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
Nov 10 '06 #5

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

Similar topics

14
12124
by: inquirydog | last post by:
Hi- One frusterating thing for me with xsl is that I don't know how to make xslt throw some sort of exception when a value-of path does not exist. For instance, suppose I have the following...
3
1725
by: gimme_this_gimme_that | last post by:
I once downloaded a shareware program that allowed you to open an xml file, click on a text or an attribute, an then see the xpath expression that would fetch that data. The program didn't...
7
1796
by: steve bull | last post by:
I have the following code snippet to read the colorRange attributes for the colorRangeSwatch in the xml file listed below. string expr = "/swatches/colorRangeSwatch/colorRange";...
2
2861
by: ree32 | last post by:
When I import an xml document in Visual studio and Genereate as schema from it, and create a dataset from it, it adds this line into to the root element of my xml file -...
5
4184
by: laks | last post by:
Hi I have the following xsl stmt. <xsl:for-each select="JOB_POSTINGS/JOB_POSTING \"> <xsl:sort select="JOB_TITLE" order="ascending"/> This works fine when I use it. But when using multiple...
5
2381
by: David Thielen | last post by:
Hi; I set up my xml as follows: XmlDocument xml = new XmlDocument(); xml.Load(File.Open("data.xml", FileMode.Open, FileAccess.Read)); XmlNamespaceManager context = new...
6
15485
by: Chua Wen Ching | last post by:
Hi there, I had this xml file with me (not yet consider implementing xml namespaces yet). <?xml version='1.0'?> <Object> <Windows> <EID>1</EID> <EDesc>Error 1</EDesc> </Windows>
4
9101
by: syed.akhlaq | last post by:
Hi, Does anyone know how can I validate XPath expressions using xsd schema? Thanks
2
4709
by: arunairs | last post by:
Hi, Is there a way of validating and XPath? In this case , I am accepting an XPath from the user and I need to validate the XPath syntax. Is there a regular expression available that anyone can...
0
7148
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
7430
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...
1
7089
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
7517
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...
1
5072
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...
0
4743
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3217
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1581
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
790
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.