TreeView w/ XmlDataSource
Posted on 2007-03-22
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:
<CHG-MOVE>123 Home St//55555</CHG-MOVE>
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
TreeView1.DataSource = xmlSource;
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:
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.