Solved

TreeView w/ XmlDataSource

Posted on 2007-03-22
1
700 Views
Last Modified: 2012-08-13
I want to display some XML in a tree view control (ASP.net page).  Unfortunately I don't have much control over the XML source data.  I suppose I could create an XSLT document, but I really don't know what the incoming XML will look like.

Here is a sample of the XML:

<CAPI>
      <CAPI-PARAMETERS>
            <CAPI-FUNCTION>SCM</CAPI-FUNCTION>
            <CAPI-SYSTEM>CIS</CAPI-SYSTEM>
            <CAPI-DICTIONARY>HIST</CAPI-DICTIONARY>
            <CAPI-MENU>HIST</CAPI-MENU>
                <CAPI-OPID>WEB</CAPI-OPID>  
            <ENTER-SET>Y</ENTER-SET>
      </CAPI-PARAMETERS>
      <CAPI-DATA>
            <CIS-SVRC>
                  <PARM-LINE>71271136</PARM-LINE>
                  <HOME-PHONE>555/123-4567</HOME-PHONE>
                  <HOME-EXTN></HOME-EXTN>
                  <WORK-PHONE></WORK-PHONE>
                  <WORK-EXTN></WORK-EXTN>
                  <NAME>Smith, John</NAME>
                  <ATTN></ATTN>
                  <DLIN></DLIN>
                  <CHG-EFF-DT>30107</CHG-EFF-DT>
                  <CHG-SRCA>INET</CHG-SRCA>
                  <CHG-SRCB>INET</CHG-SRCB>
                  <CHG-SRCC>INET</CHG-SRCC>
                  <CHG-MOVE>123 Home St//55555</CHG-MOVE>
            </CIS-SVRC>
      </CAPI-DATA>
</CAPI>


As you can see, the XML is very basic, but it has a completely different structure each and every time (depending on which database table is be requested).




My current code looks something like this:


                XmlDataSource xmlSource = new XmlDataSource();
                xmlDs.Data = xml;   // this is obtained from the database
                xmlDs.DataBind();

                TreeView1.DataSource = xmlSource;
                TreeView1.DataBind();


This appears to work just fine, with the exception that it does not display data.  It only displays the column names, not the data in the columns.

That is, my results look like:

-CAPI
      -CAPI-PARAMETERS
            CAPI-FUNCTION
            CAPI-SYSTEM
            CAPI-DICTIONARY
            CAPI-MENU
                CAPI-OPID  
            ENTER-SET
            ...
            ..
            .
etc.

So how do I get the values to display as well without a lot of hassle?  I don't need anything fancy, I just need to tidy up the XML so it is easy to read.  It currently comes back as just one long string, and not formatted like my sample of the input source.
0
Comment
Question by:_TAD_
[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 11

Accepted Solution

by:
ethoths earned 500 total points
ID: 18773087
If all you want to do is disoplay the xml in a structured format there are several ways to do it. You cold use xslt to just look for closing tags and put a crlf in the xml (as well as the appropriate number of tabs). I'm sure if you do a google you'll find an example of how do do this.

Another way would be to embed a browser control in your page and show the XML in that. That way you get color coding and brance collapsing all for free.


0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

624 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