Solved

Don't want to display root XML node in TreeView

Posted on 2006-07-12
1
757 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying 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

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

717 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