Reputation: 55
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>
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.
THank you
Upvotes: 1
Views: 7267
Reputation: 163595
There are several XSLT processors that can be invoked from C#. The Microsoft one only supports XSLT 1.0 (but that may be adequate for your needs, depending on the complexity of the transformation). There are two processors that support XSLT 2.0 for this environment: Saxon and XQSharp. Although there is a learning curve associated with XSLT, the code will be much more maintainable than any thing you write using DOM-level C# coding.
Upvotes: 1
Reputation: 4253
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
Upvotes: 3