Johan
Johan

Reputation: 11

Convert Html to XML

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

Answers (5)

Martin Pola R
Martin Pola R

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

Alexander Christov
Alexander Christov

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

Rami Alshareef
Rami Alshareef

Reputation: 7160

enter image description here

The Post

Google Link

Hope this helped..

Upvotes: 0

Deepika
Deepika

Reputation: 474

try this:

http://www.w3.org/TR/xhtml1/#diffs

Upvotes: 0

Rune Grimstad
Rune Grimstad

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

Related Questions