I am parsing an XML document that is in UTF-8 format as follows:
XDocument doc = GetXmlFeed(url);
doc.Declaration = new XDeclaration("1.0", "utf-8", "true");
var root = doc.Root;
if (year == highestYear)
data = new TourDetails()
{
TourName = root.Element("tourName").Value,
DetailedItenerary = (from a in root.Element("detailedItinerary").Descendants("detailedItineraryItem")
select new IteneraryItem()
{
Label = a.Attribute("label").Value,
Contents = a.Value
}).ToList()
};
The contents of the DetailedItinerary is in UTF-8 format. But, when we save it in the database we get weird characters like ’ and others.
How do I get Contents to be used understood to be in UTF-8 format. I assume the part that is not using UTF-8 is the a.value in the xml linq portion.
Our MySQL DB is set to use UTF-8 by default and in all the databases we're using.
Does anyone know how to fix it? Thanks!