4

I have a rather curious problem, using the XElement load method to load in a html document (which is well formed checked with HTML Tidy), which work absolutely perfectly for English documents, however moving to French and Spanish docs I'm presented with an XML Exception;

XML Exception
Invalid character in the given encoding. Line 23, position 43.

The method call

XElement doc = XElement.Load("example1.html", LoadOptions.None);

Sniplet of the html document

<font face="Arial" size="3" color="#ffffff">
Le test <b> exemple français, qui devrait éventuellement être suivie d'un texte en langue espagnole. </ b>
</font>

I realise my HTML does not have an encoding type set at the start of the file, is there a way around this?

1 Answer 1

3

because you're not using XDocument you can't set character encoding, use that instead and set encoding = UTF-8

http://msdn.microsoft.com/en-us/library/bb387063.aspx

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.