Solved

Don't want to display root XML node in TreeView

Posted on 2006-07-12
1
751 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This video discusses moving either the default database or any database to a new volume.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

708 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now