c# - Get rid of extra \ in DataContractSerializer -


i have wcf process xml , returns response(as xml) client. method return response.

 public string processxml(commonlibrary.model.transferdata dto, bool authenticated)     {          datacontractserializer dcs = new datacontractserializer(typeof(responseback));         memorystream ms = new memorystream();          utility.utilities utl = new utility.utilities();           string xmlerrmessage = string.empty;          if (authenticated)         {              if (!string.isnullorempty(dto.xml))             {                 xmlerrmessage = utl.validatexml(dto.xml, xsdfilepath, currentschema);                  if (string.isnullorempty(xmlerrmessage))                 {                     dcs.writeobject(ms, new responseback() { statuscode = 101, statusdescription = "success" });                      ms.position = 0;                 }                 else                 {                       dcs.writeobject(ms, new responseback() { statuscode = 201, statusdescription = "xml validation fails" });                     ms.position = 0;                 }               }          }         else         {               dcs.writeobject(ms, new responseback() { statuscode = 401, statusdescription = "authentication fails" });             ms.position = 0;          }          string s = new streamreader(ms).readtoend();  // xml result          return s;     } 

i testing method , 3 xmls taht returning in s.

xml #1:

  <responseback xmlns=\"http://schemas.datacontract.org/2004/07/commonlibrary.model\"             xmlns:i=\"http://www.w3.org/2001/xmlschema-instance\"><statuscode>401</statuscode><statusdescription> authentication fails</statusdescription</responseback> 

xml #2:

    <responseback xmlns=\"http://schemas.datacontract.org/2004/07/commonlibrary.model\" xmlns:i=\"http://www.w3.org/2001/xmlschema-instance\"><statuscode>101</statuscode><statusdescription>success</statusdescription></responseback> 

xml #3:

    <responseback xmlns="http://schemas.datacontract.org/2004/07/commonlibrary.model"   xmlns:i="http://www.w3.org/2001/xmlschema-instance"><statuscode>201</statuscode><statusdescription>xml validation fails</statusdescription></responseback> 

if @ xml #1 , #2 there 1 \ in front of xmls, how can rid of that: xmlns=\"http://schemas.datac

solution: looking @ result in debug mode in visual studio, showing / when print out result in text box ok.

i 100% sure datacontractserializer not produce backslashes. either looking @ values in visual studio's watch, escape strings according c# syntax, or other part of program changes xml.


Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -