CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    May 2011
    Posts
    18

    [RESOLVED] Deserilization of an XML String Fails

    I have an object that gets serialized using the XmlSerializer class. Users can input data...this data gets Serialized and then De-Serialized later.



    The input data, the user needs to be able to enter the "&" character. The input looks like so...
    Code:
    myObject.AlternateAddress1 = "Sampson & Meyes Inc.";
    myObject.AlternateAddress2 = "Lexington & Fairfield";
    myObject.AlternateAddress3 = "By the old KMart & the new Stabucks";
    myObject.AlternateAddress4 = "Washington & Heights NJ"

    After Serialization, the XML String looks like this

    Code:
    <AlternateAddress1>Sampson &amp; Meyes Inc.</AlternateAddress1>
    <AlternateAddress2>Lexington &amp; Fairfield</AlternateAddress2>
    <AlternateAddress3>By the old KMart &amp; the new Stabucks</AlternateAddress3>
    <AlternateAddress4>Washington &amp; Heights NJ</AlternateAddress4>
    The problem I'm having is the Data seems to get Serialized just fine. It is erroring when trying to DeSerialize the info back into the object. It apparantly doesn't like the "&amp;". Not sure why since the Serializer put it there...

    Any thoughts on how to get around this?

  2. #2
    Join Date
    May 2011
    Posts
    18

    Re: Deserilization of an XML String Fails

    I found out the issue and was with a "helper" libarary of ours. There was a function where we were decoding the XML using HttpUtility.Decode before allowing the serializer to decode it too. This was causing the &amp; to turn into & and that was blowing up the serializer.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured