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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:25:16+00:00 2026-05-22T21:25:16+00:00

I am seeing a difference between the way XmlDocument Load( ) and LoadXml( )

  • 0

I am seeing a difference between the way XmlDocument Load( ) and LoadXml( ) work in .NET 2.0. Given the XML document below (note the use of a right quote, ascii code 146):

<?xml version="1.0" encoding="utf-8"?>
<nodes>
  <node>Some Data ’</node>
</nodes>

Why does it load fine with LoadXml( ) when passed in as a string but fails if passed in to Load( ) as a document. I.E. and other XML editors also will not load and display this file.

Simplified Code Example:

[WebMethod]
public bool SubmitData(string xmlDoc)
{
   try
   {
      XmlDocument doc = new XmlDocument();
      doc.LoadXml(xmlDoc);
   }
   catch
   {
      return false;
   }

   return true;
}

I know the code is poor but it is just meant to demonstrate the problem. If the string “xmlDoc” is not a legitimate xml document, then I am trying to get this to fail.

I can’t control the content of the XML sent to me. I just receive it and work with it through the web service. Apparently, the people calling it are copying and pasting data from a Word Doc. I didn’t design this either but I am stuck maintaining it. 🙂

  • 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-05-22T21:25:17+00:00Added an answer on May 22, 2026 at 9:25 pm

    The difference is the encoding. When loading from a file, utf-8 decoding is applied and your code 146 is probably not valid utf-8 in your case. LoadXml ignores the encoding because .Net strings do not need to be decoded. Therfore your special character is a valid character and everything is fine.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm seeing conflicting references in Oracles documentation . Is there any difference between how
I'm seeing a difference in the output from Url.RouteUrl between my development machine and
I'm seeing an interesting behavior difference between my instance and my boss's instance of
Seeing as you can convert any document to a byte array and save it
I was seeing today the addslashes and addcslashes in php.net, but did not get
I am seeing a conflict between what Rails 3.1 guides suggest, and what Google
I am looking to find out the difference between the spring:bind and form:form tag
The difference between to datetimes is the number of seconds between them. This seems
I'm currently working on a class that calculates the difference between two objects. I'm
What is the difference between Start Debugging ( F5 ) and Start without Debugging

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.