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 8539565
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:23:45+00:00 2026-06-11T11:23:45+00:00

I am trying to parse the string contents of an XML file that contains

  • 0

I am trying to parse the string contents of an XML file that contains special characters in to an XDocument for further processing when I keep getting the following error:

Name cannot begin with the ‘.’ character, hexadecimal value 0x00. Line 1, position 8.

I do not have control over this file. All I can do is parse it from a network share that I have read access to. The file contents are as follows:

<?xml version="1.0" encoding="utf-16"?>
<ns0:SAEErr xmlns:ns0="http://xyz">
<ErrorInformation>olsfdhfaskldhfksajdfkajsf</ErrorInformation>
<OriginalMessage>慐浹湥䥴Ɽ慐浹湥却慴畴䍳摯ⱥ慐</OriginalMessage>
</ns0:SAEErr>

The code to parse the file above is as follows:

StringBuilder sb = new StringBuilder();
        sb.Append("<root>");
        sb.Append(FileUtil.ReadFileContent(fileName));
        sb.Append("</root>");

        return XDocument.Parse(sb.ToString());        

What am I missing here?

Thanks in advance!

UPDATE: The following code update did it:

 XElement body = XElement.Load(fileName);

 return new XDocument(new XDeclaration("1.0", "utf-16", "no"), body);

Thanks Henk!

  • 1 1 Answer
  • 0 Views
  • 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-06-11T11:23:47+00:00Added an answer on June 11, 2026 at 11:23 am

    When reading the file with XElement.Load() I can only reproduce your error after change utf-16 to utf-8 in the processing line. So it is indeed an Encoding error.

    Edit:

    Your code:

      StringBuilder sb = new StringBuilder();
      sb.Append("<root>");
      sb.Append(FileUtil.ReadFileContent(fileName));  // Encoding ??
      sb.Append("</root>");
      return XDocument.Parse(sb.ToString()); 
    

    Try:

      XElement body = XElement.Load(fileName); 
      XDocument doc = new XDocument(new XElement( "root", body));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to parse an xml file that contains accents, but I get this
I am trying to parse the contents of http://feeds.feedburner.com/riabiz using XDocument.Parse(string) (because it gets
I am trying to parse an XMl document that i received into a string
I'm trying to parse the contents of an remote XML file into MySQL, so
I'm trying to use XPath to parse an XML string but I am getting
here i am just trying to parse an xml file and store the contents
I'm trying to parse a string that was generated by an NSDateFormatter using another
I am getting an error when trying to parse a string to datetime. I
I am getting the strangest error, when trying to parse a string as a
I'm trying to parse an xml file to return a item with a specific

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.