easiest way to display xml tree structure in aspx
I need the easiest way to display xml tree structure in aspx - nothing fancy!
this is my xml - which i am reading from a file on the hdd
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<citizenvitalsign>
<citizenid>v56456</citizenid>
<logopendate>2011-05-05</logopendate>
<logexpiredate>2011-05-20</logexpiredate>
<vitalsigns>
<vitalsigndate>2011-05-04</vitalsigndate>
<vitalsignstime>12:34:23</vitalsignstime>
<signs>
<oximeter>
<saturationlevel>56</saturationlevel>
<heartrate>84</heartrate>
</oximeter>
<weigth>
<weigthingrams>75100</weigthingrams>
</weigth>
<ecg>
<ecgvalues>
<value>0.00432</value>
<value>0.00532</value>
<value>0.00832</value>
<value>0.00432</value>
<value>0.00532</value>
<value>0.00832</value>
</ecgvalues>
</ecg>
<bloodpressure>
<systolic>78</systolic>
<diastolic>123</diastolic>
<heartrate>89</heartrate>
</bloodpressure>
</signs>
</vitalsigns>
<vitalsigns>
<vitalsigndate>2011-05-05</vitalsigndate>开发者_运维知识库;
<vitalsignstime>10:35:23</vitalsignstime>
<signs>
<oximeter>
<saturationlevel>56</saturationlevel>
<heartrate>84</heartrate>
</oximeter>
<ecg>
<ecgvalues>
<value>0.004456</value>
<value>0.00532</value>
<value>0.000434</value>
<value>0.00489</value>
<value>0.005122</value>
<value>0.008122</value>
</ecgvalues>
</ecg>
<bloodpressure>
<systolic>85</systolic>
<diastolic>111</diastolic>
<heartrate>90</heartrate>
</bloodpressure>
</signs>
</vitalsigns>
If the whole contents of the aspx
is the XML content:
Just output a application/xml
(or text/xml
, though see the link in the comment by @jasso first) content type header with your XML and let the browser show the XML in the native way.
Most browsers already show XML in a tree structure natively.
If you want to output it as part of the page output, with other content, I would pass the XML through an XML pretty printer and then HTML encode it for output.
You can use Literal
control along with Server.HtmlEncode
to show the xml.
Example here: Display XML on an ASP.NET page
精彩评论