Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 943471
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T22:26:36+00:00 2026-05-15T22:26:36+00:00

I receive an XML file with encoding ISO-8859-1 (Latin-1) Within the file (among other

  • 0

I receive an XML file with encoding “ISO-8859-1” (Latin-1)

Within the file (among other tags) I have <OtherText>Example &quot;content&quot; And &#9472;</OtherText>

Now for some reason when I load this into XMLTextReader and do a “XmlReader.Value” to return the value, it returns: "content" And ─

This then, when confronted with a database only accepting Latin-1 encoding, obviously errors.

I have tried the following:

  • Converting into bytes and using
    Encoding.Convert to change from UTF-8
    into Latin-1 (which successfully
    gives me a bunch of “?” instead)
  • Using
    StreamReader(file,Encoding.whatever)
    to load the file into XmlTextReader

And several variations there-of and different methods on the internet and on StackOverflow istelf.

I understand that .NET strings are UTF-16, but what I don’t understand is why, a fully Latin-1 formatted XML file with CORRECT markup for when UTF-8 characters exist which is compatible with older databases AND the web (for HTML markup etc) that it simply overrides that and output’s the UTF-8 encoded string ANYWAY.

Is there noway to get around this other than writing my own custom text parser???

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T22:26:37+00:00Added an answer on May 15, 2026 at 10:26 pm

    I do not believe this is a problem with the encoding. What you’re seeing is the XML string being un-escaped.

    The problem is &quot; is a XML escape character, so XMLTextReader will un-escape this for you.

    If you change this:

    <OtherText>Example &quot;content&quot; And &#9472;</OtherText>
    

    To this:

    <OtherText>Example &amp;quot;content&amp;quot; And &amp;#9472;</OtherText>
    

    Then

       XmlReader.Value = "&quot;content&quot; And &#9472;";
    

    You’ll need to wrap your value in CDATA so it is ignored by the parser.

    Another option is to re-escape the string:

        using System.Security;
    ....
    ....
        string val = SecurityElement.Escape(xmlReader.Value);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an xml file like this one: receipt.xml <?xml version=1.0 encoding=ISO-8859-1?> <?xml-stylesheet type=text/xml
Given the following XML file: <?xml version=1.0 encoding=UTF-8?> <process name=TestSVG2 xmlns=http://www.example.org targetNamespace=http://www.example.org xmlns:xsd=http://www.w3.org/2001/XMLSchema> <sequence>
I receive a daily XML file that contains thousands of records, each being a
I have an XML reader but I receive an error when I'm trying to
I have looked at many examples for validating an XML file against a DTD,
I have a sample htm file with following structure and it POSTs the xml
I have a file i receive from a blackbox system, the file is somehow
I have an xml document: <?xml version=1.0 encoding=utf-8?> <Root> <Child name=MyType compareMode=EQ></Child> </Root> And
I am trying to marshall data within an object into an xml file based
I have a file, which is in XML format (consists just of root start

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.