如何将XML转换为HTML在C#? [英] How to convert XML to Html in c#?

查看:113
本文介绍了如何将XML转换为HTML在C#?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是将XML转换为HTML的最佳方式,目前我使用的XPathNavigator和声明XPathNodeIterator查询和遍历XML。这工作得很好,但我需要这个XML转换为HTML,并将其显示在浏览器中的一些表,这是实现这一目标的最佳途径。和XML是不是永远不变,我的意思是动态生成的XML。 XML如下:

Which is the best way to convert xml to html, currently i am using Xpathnavigator and xpathnodeiterator to query and traverse the xml. This works fine, but i need to convert this xml to html,and display it in browser with some tables, which is the best way to achieve this. And the xml is not constant always, i mean the xml is generated dynamically. Xml is below:

- 
<win32_networkadapter>
<entity>
  <index>1</index> 
  <speed /> 
  <manufacturer /> 
  <pnpdeviceid /> 
  <name>RAS Async Adapter</name> 
  <adaptertype /> 
  </entity>
- <entity>
  <index>2</index> 
  <speed /> 
  <manufacturer>Microsoft</manufacturer> 
  <pnpdeviceid>ROOT\MS_L2TPMINIPORT\0000</pnpdeviceid> 
  <name>WAN Miniport (L2TP)</name> 
  <adaptertype /> 
  </entity>
</win32_networkadapter>

这个XML包含在一个系统中网络适配器的详细信息,以获得WMI是使用细节和xml是动态生成的。这样一个系统可以包含2个网络适配器在上述XML和其他系统可以包含在这种情况下,XML生长3或4的网络适配器。在这种情况下,怎么能生成此XML动态HTML。显示在浏览器中的表网络的详细信息。

This xml contains the details of the network adapters in a system, to get details wmi is used and xml is generated dynamically. So one system may contain 2 network adapter as in the above xml and other system may contain 3 or 4 network adapters in which case the xml grows. In this case how can generate html from this xml dynamically. Display the network details in tables in browser.

感谢您

推荐答案

而不是转换XML到HTML可以样式化XML文档本身,你可以阅读更多有关的文档,W3为XML样式的,用CSS 造型XML文档添加风格顺应XML

Instead of converting xml to html you can style the xml document itself, you can read more about that documentation, w3 for xml stylesheets, Styling XML Documents with CSS and adding style to xml

这篇关于如何将XML转换为HTML在C#?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆