Get values

S

shapper

Hello,

I am trying to load information from a XML file using only the nodes
which attribute footer=true.

I created the following code:

Dim siteMap As New System.Xml.XmlDocument
siteMap.Load(HttpContext.Current.Server.MapPath(Me.SiteMapUrl))
Dim siteMapNodeList As XmlNodeList =
siteMap.SelectNodes("sitemapnode[@footer='true']")
Dim iSiteMapNode As Integer

' Loop through each node in XML node list
For iSiteMapNode = 0 To siteMapNodeList.Count - 1

' Create new hyperlink
Dim link As New HyperLink

' Define hyperlink properties
With link
.ID = "by27f_h" &
siteMapNodeList(iSiteMapNode).Attributes("title").Value
.NavigateUrl =
siteMapNodeList(iSiteMapNode).Attributes("url").Value
.Text =
siteMapNodeList(iSiteMapNode).Attributes("title").Value
.ToolTip =
siteMapNodeList(iSiteMapNode).Attributes("title").Value
End With

Next

I am not getting anything.

My XML file is as follows:

<?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 you tell me what am I doing wrong?

I can't understand why I don't get any values.

Thanks,
Miguel
 
K

Kevin Spencer

Try using a System.Xml.XPath.XPathNavigator to navigate your XmlDocument, by
using the CreateNavigator method:

http://msdn2.microsoft.com/en-us/library/system.xml.xmldocument.createnavigator.aspx

The XPathNavigator class allows you to navigate in all directions in an
XmlDocument, using XPath expressions:

http://msdn2.microsoft.com/en-us/library/system.xml.xpath.xpathnavigator.aspx

--
HTH,

Kevin Spencer
Microsoft MVP
Ministry of Software Development
http://unclechutney.blogspot.com

I just flew in from Chicago with
a man with a wooden leg named Smith
who shot an elephant in my pajamas.
So I bit him.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,740
Latest member
JudsonFrie

Latest Threads

Top