Home > Net >  The problem of XML webservice serializing access to class structure
The problem of XML webservice serializing access to class structure

Time:11-11

To ask, I defined the two entities, the serialized XML format is as follows, there are two to remove node place, could you tell me how to remove
in the codeO
<? The XML version="1.0" encoding="utf-8"?>
XMLNS="http://tempuri.org/" & gt;

0 & lt;/ResultCode>
Data acquisition success & lt;/ResultContent>

- to remove
Zhang & lt;/Name>
Clinic & lt;/Dept>
1001 & lt;/BM>





Structure
Public class Response
{

[System. Xml Serialization. XmlElement (IsNullable=true)]
[DataMember]
Public string the ResultCode {get; set; }
[DataMember]
Public string ResultContent {get; set; }
[DataMember]
Public List Data {get; set; }
}
Public class EUSERINFO
{

[System. Xml Serialization. XmlElement (IsNullable=true)]
[DataMember]
Public string Name {get; set; }
[System. Xml Serialization. XmlElement (IsNullable=true)]
[DataMember]
Public string Dept {get; set; }
[System. Xml Serialization. XmlElement (IsNullable=true)]
[DataMember]
Public string BM {get; set; }

}

Public string XmlSerialize Obj (T)
{
XmlSerializer xs=new XmlSerializer (obj. GetType ());
MemoryStream ms=new MemoryStream ();
//set the order ordering XML format
XmlWriterSettings XWS=new XmlWriterSettings ();
XWS. Indent=true;
XWS. OmitXmlDeclaration=true;
XWS. Encoding=Encoding. UTF8;

Using (XmlWriter XTW=XmlTextWriter. Create (ms, XWS))
{

XmlSerializerNamespaces _namespaces=new XmlSerializerNamespaces (
New XmlQualifiedName [] {
New XmlQualifiedName (string. The Empty string. Empty)
});
Xs. Serialize (XTW, obj, _namespaces);
Ms. Position=0;
XTW. Close ();
}
Byte [] b=Ms. ToArray ();
String s=System. Text.. Encoding UTF8. Get string (b, 0, b.L ength);
Return s;

}

CodePudding user response:

[the WebMethod]
Public string USER (string Requestparam)
{
Try
{
EUSER_Request _EUSER=DESerializerThe Response _EUSER_Response=new Response ();
IEnumerable MgetEUSERINFO=_EUSER_Response. GetEUSERINFO (_EUSER. UserName. The Trim (), _EUSER. Dept., the Trim (), _EUSER. UserCode. The Trim ());
If (mgetEUSERINFO==null)
{
_EUSER_Response. The ResultCode="1";//=new EUSER_Response () {the ResultCode="1", ResultContent="data acquisition failure", mEUSERINFO=};
_EUSER_Response. ResultContent="data acquisition failure";
}
The else
{
_EUSER_Response. The ResultCode="0";//=new EUSER_Response () {the ResultCode="1", ResultContent="data acquisition failure", mEUSERINFO=};
_EUSER_Response. ResultContent="data acquisition success";
_EUSER_Response. Data=https://bbs.csdn.net/topics/(List ) mgetEUSERINFO;
}

XML string=XmlSerialize (_EUSER_Response);

//string filepath=AppDomain. CurrentDomain. BaseDirectory + "User. XML";
Return the XML.
}
Catch
{
Return a string. The Empty;
}
}

CodePudding user response:

The
refer to the original poster danny_2020 response:
{
.
[DataMember]
Public List Data {get; set; }
}
.

If List Under Data two EUSERINFO, what would you do?

CodePudding user response:

According to


Zhang & lt;/Name>
Clinic & lt;/Dept>
1001 & lt;/BM>


Doctor li & lt;/Name>
The inpatient & lt;/Dept>
1002 & lt;/BM>

  • Related