Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Don't want to display root XML node in TreeView

Posted on 2006-07-12
1
Medium Priority
?
760 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 750 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

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…
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.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

618 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