I am using Visual Studio 2013 Ultimate with SQL Server 2008 R2 version.
我正在使用Visual Studio 2013 Ultimate和SQL Server 2008 R2版本。
I have created my web service from which I return the custom XML in StringBuilder data to my desktop application (C#).
我已经创建了我的Web服务,我将StringBuilder数据中的自定义XML返回到我的桌面应用程序(C#)。
So my question is how to store that XML and how to read it?
所以我的问题是如何存储XML以及如何阅读它?
Demo of my custom xml data:
演示我的自定义xml数据:
<TableName>students
<row>
<StudentId><![CDATA[1]]></StudentId>
<StudentName><![CDATA[abc]]></StudentName>
<Password><![CDATA[password]]></Password>
</row>
</TableName>
This is just one example of data, there are multiple data coming like this format.
这只是数据的一个例子,有多种数据就像这种格式。
Please someone help me how to store and read this XML!
请有人帮我如何存储和阅读这个XML!
1 个解决方案
#1
0
Try with this -
试试这个 -
public class TableName
{
public Students students { get; set; }
}
[XmlRoot(ElementName = "students")]
public class Students
{
[XmlElement(ElementName = "row")]
public List<Row> Rows { get; set; }
}
public class Row
{
public string StudentId { get; set; }
public string StudentName { get; set; }
public string Password { get; set; }
}
var ser = new XmlSerializer(typeof(TableName));
var def = new XmlSerializerNamespaces();
def.Add("", "");
var obj = ser.Deserialize("xmlPath");
#1
0
Try with this -
试试这个 -
public class TableName
{
public Students students { get; set; }
}
[XmlRoot(ElementName = "students")]
public class Students
{
[XmlElement(ElementName = "row")]
public List<Row> Rows { get; set; }
}
public class Row
{
public string StudentId { get; set; }
public string StudentName { get; set; }
public string Password { get; set; }
}
var ser = new XmlSerializer(typeof(TableName));
var def = new XmlSerializerNamespaces();
def.Add("", "");
var obj = ser.Deserialize("xmlPath");