To use a specific encoding when working with XDocument, you can create an XDeclaration.


C# Sample

XDocument xDoc = new XDocument();
xDoc.Declaration = new XDeclaration("1.0", "ISO-8859-1", "");

VB.NET Sample

Dim xDoc As New XDocument()
xDoc.Declaration = New XDeclaration("1.0", "ISO-8859-1", "")

If you have any questions or suggestions feel free to rate this snippet, post a comment or Contact Us via Email.

Related links:

Leave a Reply