Get Value from XML node

S

shapper

Hello,

I created a XmlNodeList as follows:

Dim siteMap As XmlDocument = New XmlDocument
siteMap.Load("~/Web.sitemap")

' Get Node List using XPath
Dim siteMapNodeList As XmlNodeList =
siteMap.SelectNodes("sitemapnode[@footer='true']")
Dim siteMapNode As XmlNode

Now I want to go trough each node and get the value of "title" and
"url" attributes to use in a Bulleted List. My problem is tho get those
values

' Loop through each node in XML node list
For Each siteMapNode In siteMapNodeList
MyBulletedList.Items.Add(New
ListItem(siteMapNode.Attributes("title"),
siteMapNode.Attributes("url")))
Next

How can I do this?

Thanks,
Miguel

P.S: Here is the XML file I am using. I think my VB.Net code is well
done ... at least I hope.

<?xml version="1.0" encoding="utf-8" ?>
<siteMap
xmlns = "http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode>
<siteMapNode
url = "~/default.aspx"
description = "des"
title = "Página Inicial"
footer = "true" />
<siteMapNode
url = "~/collection.aspx"
description = "desc"
title = "Colecção"
footer = "false" />
<siteMapNode
url = "~/contacts.aspx"
description = "desc"
title = "Contactos"
footer = "true" />
</siteMapNode>
</siteMap>
 

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

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,060
Latest member
BuyKetozenseACV

Latest Threads

Top