0
我想分析下面的XML文本類的反對解析XML文本類在C#
XML:
<?xml version="1.0" encoding="UTF-8"?><data><Error><![CDATA[No Error]]></Error></data>
類:
public class AAA
{
public BBB data;
}
public class BBB
{
public string Error;
}
代碼:
XmlSerializer serializer = new XmlSerializer(typeof(DUserInfo));
using (StringReader reader = new StringReader(xmlText))
{
AAA info = (AAA)(serializer.Deserialize(reader));
}//using
錯誤:
There is an error in XML document (1, 40).
<data xmlns=''> was not expected.
我希望你不介意編輯。感覺最好只是將這些額外信息添加到您的答案中,因爲它只是擴展了您所說的內容...... –
@ VC.One感謝您的編輯,它的良好精神。這將有助於OP。 –
@viveknuna我編輯了問題 – SajjadZare