Okay, what I'm asking is how do I iterate through that nodelist that is created.
Main Topics
Browse All TopicsPlatform is .NET 2.0 VB. I have an application using the menu control for a navigation system. I have an XML file that represents several different attributes about reports. I want to append menu items to this existing menu by reading through that XML file.
Current menu control code:
<asp:Menu id="myMenu">
<items>
<asp:MenuItem Text="Menu 1">
<asp:MenuItem Text="Menu 1 option 1" />
</asp:MenuItem>
<asp:MenuItem Text="Menu 2">
<asp:MenuItem Text = "Menu 2 option 1" />
<asp:MenuItem Text = "Menu 2 option 2" />
</asp:MenuItem>
</Items>
</asp:Menu>
My XML file looks like this:
<reports>
<report id="1">
<id>1</id>
<rname>Report Name 1</rname>
<rurl>Report URL</rurl>
<enabled>true</enabled>
</report>
<report id="2">
<id>2</id>
<rname>Report Name 2</rname>
<rurl>Report URL</rurl>
<enabled>false</enabled>
</report>
<report id="3">
<id>3</id>
<rname>Report Name 3</rname>
<rurl>Report URL</rurl>
<enabled>true</enabled>
</report>
</reports>
There are other elements in the XML file which I am using elsewhere -- when a report is selected by its "id" number, it determines which elements on the filter screen are visible, etc. This is working great.
What I want to do is, in the PageLoad event of the menu custom control codebehind, read in the XML file, and if the report is enabled, add it (in id order) to the second submenu, like:
myMenu.Items(1).ChildItems
But I can't seem to understand how to iterate through the list of matching list items in the XML file (the 'enabled' ones) and then break out the various element values to manipulate them in this fashion. What am I missing? Need guidance on how to read in the contents of the XML file, and how to access the various elements to build the menu items.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
I've attempted to use the SelectNodes as displayed, and either I'm not actually getting anything back (which should not be true as I know I have items that are enabled) or I'm confused as to how to iterate across them, because I get nothing returned.
I'm offering 500 points for what should be fairly simple for someone who works with XML, so please take the time to write out how this works.
I know I have matching items in the xml file. But I'm getting nothing. I've put stuff within the for each loop and I can tell that I'm not even getting into the loop.
I went a different route by reading the XML set into a DataView and that's working for me now. Thanks anyway but I have resolved my problem.
My solution:
Dim dvReport As New DataView
Dim rid As Integer
dvReport = CType(XMLFile.GetReportLis
...
Public Function GetReportList() As System.Object
If HttpContext.Current.Cache(
Dim xmlReportList As New DataSet
xmlReportList.ReadXml(xmlP
Dim xmlView As DataView
xmlView = xmlReportList.Tables(0).De
HttpContext.Current.Cache.
End If
Return HttpContext.Current.Cache(
End Function
Business Accounts
Answer for Membership
by: vardiumPosted on 2007-07-25 at 02:36:26ID: 19563881
You can use XML Query like : nabled='tr ue']")
Dim doc as XmlDocument = new XmlDocument()
doc.Load("YOURXML.xml")
Dim root as XmlNode = doc.DocumentElement
Dim nodeList as XmlNodeList = root.SelectNodes("report[e
Now nodeList contains only enabled report nodes, you can use them with foreach as you want.