Reputation: 11
My assignment is to convert an html file to XML format. I'm working with C#/.NET. Any suggestions? Thanks heaps
Upvotes: 1
Views: 8989
Reputation: 1
I ran into a situation where I was writing out xml via Response.Write(...); with c#. I simply needed to convert the html to an xml file. I was able convert the file using the following:
Response.ContentType = "text/xml";
Hope this helps someone.
Upvotes: 0
Reputation: 10045
Try SgmlReader, I personally used it couple of times and the results are impressive.
You can add it to your project as a NuGet package as well.
Upvotes: 1
Reputation: 36340
I would try using the Html Agility Pack to parse the Html. This would allow me to build either an object graph that I could output as Xml or I could use the parsed Html to output the Xml directly.
Alternatively, if you have full control of the Html and know it is XHtml compliant, you could do a simple XSL-transform on the Html to get the Xml you want. But is most cases you cannot do this.
Upvotes: 4