Solved

Don't want to display root XML node in TreeView

Posted on 2006-07-12
1
755 Views
Last Modified: 2009-04-08
I'm Using Visual Studio 2005, FrameWork 2.0, ASP.NET 2.0

I have a Web page with a TreeView control, which is bound to filename StaffMenu.xml. Here is StaffMenu.xml:

<?xml version="1.0" encoding="utf-8" ?>

<Staff>
    <Menu name="Smith, Betty" url=""/>
    <Menu name="White, Gary" url=""/>
    <Menu name="Johnson, William" url=""/>
 </Staff>

Here is the TreView:

<asp:TreeView
        ID="TreeView1"
        runat="server"
        DataSourceID="XmlDataSource3" >
        <DataBindings>
            <asp:TreeNodeBinding
                DataMember="Menu"
                TextField="name"
                NavigateUrlField="url" />
        </DataBindings>
     </asp:TreeView>

Here is the binding:

<asp:XmlDataSource ID="XmlDataSource3" runat="server"  
    DataFile="~/App_Data/StaffMenu.xml" >
</asp:XmlDataSource>

I don't wan't the root node ("Staff") visible in the menu. The XML needs a root element, so I can't omit it. Can it be hidden somehow when TreeView displays the menu on the Web page, so the user only sees the three names?
0
Comment
Question by:LarryZ
1 Comment
 
LVL 2

Accepted Solution

by:
psk1 earned 250 total points
ID: 17196803
<asp:XmlDataSource ID="XmlDataSource1" runat="server" XPath="/Staff/*"></asp:XmlDataSource>

The XPath expression filtes out the top root node and displays the rest of the nodes.

(from http://lakshmik.blogspot.com/2006/04/aspnet-binding-xml-data-to-treeview.html)
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question