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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:04:54+00:00 2026-06-01T20:04:54+00:00

I am making a program that will store its data in an XML file.

  • 0

I am making a program that will store its data in an XML file. When people write XML they can make subtle mistakes, like ending a comment with - so it looks like <!-- comment ---> or adding a </>inside an attribute. Naturally, the XML still can be read all right, but trying to input this text into XmlDocument will give a syntax error (and it wont be parsed).

Is there a way to make XmlDocument less strict and make it ignore violations of the standard that do not make the document unparseable? For example, its clear that <!-- comment ---> is still a comment even though it contains - at the end which is against the standard specification).

  • 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-01T20:04:55+00:00Added an answer on June 1, 2026 at 8:04 pm

    No, XML parsers are expected to reject input that is not valid XML.

    You may try your luck preprocessing the invalid files by Tidy, but better simply make sure the input is valid.

    Here’s an example usage. Tidy will fix your comments and do some escaping, but an extra opening < will break things up more often than not – guessing in that case is simply too much to ask.

    Tidy tidy = new Tidy();
    tidy.Options.FixComments = true;
    tidy.Options.XmlTags = true;
    tidy.Options.XmlOut = true;
    
    string invalid = "<root>< <!--comment--->></root>";
    MemoryStream input = new MemoryStream(Encoding.UTF8.GetBytes(invalid));
    MemoryStream output = new MemoryStream();
    tidy.Parse(input, output, new TidyMessageCollection());
    // TODO check the messages
    
    string repaired = Encoding.UTF8.GetString(output.ToArray());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a program that will output lines to a text file. I don't
Ok, so I'm making a program that will read from a text file, convert
I am trying to learn python and am making a program that will output
I currently store a serialized XML file in the application directory that contains all
I'm making a program in Java that reads in some stuff from a file
I'm making a back-end function for another area of a program that will add
I'm trying to make a bash script that will talk to a java program
I am making a program that reads and stores data from Windows EventLog files
I'm making a program that will display a few images from a directory beside
I'm making a program that will have a widget that has to be fixed

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.