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

  • Home
  • SEARCH
  • 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 5937937
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T15:36:47+00:00 2026-05-22T15:36:47+00:00

I receive a an xml string from third party. The xml string contains invalid

  • 0

I receive a an xml string from third party. The xml string contains invalid characters like & and ‘. I am trying to put it in dataset (ASP.NET). it throws error. Can anyone pls help.

  • 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-22T15:36:47+00:00Added an answer on May 22, 2026 at 3:36 pm

    Tell/ask the third party to provide valid XML.

    Interoperability standards don’t count for much when they aren’t adhered to. If they are passing you invalid characters today, what’s to stop them from passing mismatched nodes tomorrow? or no tags at all?

    If there is no standard, then there are an endless number of scenarios for which you might need to code around.

    That said, you can:

    • Ensure that it is not a problem in your code (post code if you want specifics).
    • Create a configurable list of known find/replace scenarios and pre-process your input “XML” string.
    • If data integrity isn’t important (personally, I think it always is), you can load your data into an HTML parser, which will be far more forgiving and allow XML DOM-like document access.

    Per the OP’s comment, here is a very, very simple example of a somewhat configurable find/replace.

    public string PreProcessXml( string xml )
    {
        // this list could be read from a config file
    
        List<Tuple<string, string>> replacements = new List<Tuple<string, string>>();
    
        // Important: if there are VALID uses of an ampersand in your document, 
        // this may invalidate them! Perform a more elaborate check using a 
        // regex, or ensure that there are no valid entities already in the document.
        replacements.Add( new Tuple<string, string>( "&", "&amp;" ) );
    
        replacements.Add( new Tuple<string, string>( "\"", "&quot;" ) );
        replacements.Add( new Tuple<string, string>( "\'", "&apos;" ) );
    
        foreach( var replacement in replacements )
        {
            xml = xml .Replace( replacement.Item1, replacement.Item2 );
        }
    
         return xml;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My application receive strings from outside and construct an XML document string fromOutside =
Currently I am trying to parse an xml string that I already have (no
I will need to be able to receive this xml data from a Java
I am reading attempting to load XML from a ByteArray as follows: var xmlString:String
I'm trying to send XML doc to server from client. But when server get
I try to define a schema for XML documents I receive. The documents look
I would like to receive suggestions on the data generators that are available, for
I'd like to receive error logs via email. For example, if a Warning-level error
I am working on a small project that is receiving XML data in string
I have to code a Java program that will receive messages from network and

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.