0
我得到的xml響應是這樣的,當我試圖反序列化它的對象我無法做到這一點。值變爲空。如何反序列化對象的xml響應
我的迴應是這裏
<response>
<lst name="responseHeader">
<int name="status">0</int>
<int name="QTime">15</int>
</response
response res = new response();
XmlDocument doc = new XmlDocument();
doc.LoadXml(XmlString);
XmlNodeReader reader = new XmlNodeReader(doc.DocumentElement);
XmlSerializer ser = new XmlSerializer(res.GetType());
object obj = ser.Deserialize(reader); // Then you just need to cast obj into whatever type it is, e.g.: response myObj = (response)obj;
public class response
{
public string responseHeader { get; set; }
public int status { get; set; }
public int QTime { get; set; }
}
我的反應是在這裏 0 15個 –
Anu
2012-04-03 12:50:39
響應RES =新的響應(); XmlDocument doc = new XmlDocument(); doc.LoadXml(XmlString); XmlNodeReader reader = new XmlNodeReader(doc.DocumentElement); XmlSerializer ser = new XmlSerializer(res.GetType()); object obj = ser.Deserialize(reader); //然後你只需要將obj轉換成任何類型,例如: 響應myObj =(response)obj; 公開課回覆 { public string responseHeader {get;組; } public int status {get;組; } public int QTime {get;組; } } – Anu 2012-04-03 12:51:01