You are here:   Articles
  |  Login

Programming Articles

Minimize
12

If you are using an Asp.net menu control with an Xml file, you may have a problem in that the root node is displayed.

For example, if your Xml file looks like this:

<Menu>
 <Item name="Item 1">
  <Item name="Item 1 1" />
  <Item name="Item 1 2" />
 </Item>
 <Item name="Item 2">
  <Item name="Item 2 1" />
  <Item name="Item 2 2" />
 </Item>
</Menu>

Your Asp.net menu control might display this:

Menu
  Item 1
     Item 1 1
     Item 1 2
  Item 2
     Item 2 1
     Item 2 2

But, you do not want the word Menu displayed first. What you want is this:

Item 1
   Item 1 1
   Item 1 2
Item 2
   Item 2 1
   Item 2 2

The way to eliminate the word Menu is to specify an Xpath attribute so only the Items are returned from the Xml file, like this:

<asp:XmlDataSource
XPath="Menu/Item"

Posted in: Asp.net

Post Rating

Comments

There are currently no comments, be the first to post one.

Post Comment

Only registered users may post comments.

Programmer Newsletter

Minimize

Subscribe to the Internet Handholding newsletter



Reccomend Programmer.bz

Minimize

Share/Bookmark Bookmark and Share