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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:31:40+00:00 2026-05-27T02:31:40+00:00

I have a web service that returns an xml string as results. The return

  • 0

I have a web service that returns an xml string as results. The return string is in this format:

<ReturnValue>
   <ErrorNumber>0
</ErrorNumber>
<Message>my message</Message>
</ReturnValue>

The data that I want to insert into the “message” tag is a serialized version of a custom object. The serialized format of that object contains xml and namespace declarations post serialization. When that gets thrown into the “message” tag of my return xml string, XmlSpy says that it’s not well-formed. How should I get rid of the namespace declarations, or is there a different way to imbed a serialized object into an xml string?

  • 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-27T02:31:40+00:00Added an answer on May 27, 2026 at 2:31 am

    Just make sure that your <Message> XML is encoded so that <, >, ", and & show up as &lt;, &gt;, &quot; and &amp;, respectively.

    There are few built-in ways to encode the characters:

    string message = System.Web.HttpUtility.HtmlEncode(serializedXml);
    
    string message = System.Security.SecurityElement.Escape(serializedXml);
    
    • Using an XmlTextWriter to do the work for you
    • Use CDATA to wrap your XML

    Also, this is probably a duplicate of:

    1. Best way to encode text data for XML
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a SOAP web service that returns an XML in this format <SOAP-ENV:Envelope
I have a third party web service that returns this xml <book> <release_date>0000-00-00</release_date> </book>
I have a synchronous web service call that returns a message. I need to
I have a web service that returns a simple object: [System.CodeDom.Compiler.GeneratedCodeAttribute(System.Xml, 2.0.50727.4927)] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()]
Oh hello there, fellow SO members, I have a web service that returns XML
I have a WCF web service that returns a string to a Java based
I have a C# Web Service that returns a XML as a result that
I have a web service that returns the binary array of an object. Is
I have a WSE web service that returns a list of items in a
I have a web service which has a generic function that returns a dataset

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.