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

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 1722
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
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
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
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
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
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
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
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
by: syed.akhlaq | last post by:
Hi, Does anyone know how can I validate XPath expressions using xsd schema? Thanks
2
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
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: 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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...

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.