数据类型特定的DataTable如何从XML如何从XML
获取数据类型具体的DataTable这是我的代码
string XMLReportFormat [email protected]"<?xml version="1.0" encoding="utf-8" ?>
<Table>
<ReportBody>
<TableRow>
<ID>1</ID>
<ParentID>1</ParentID>
<Key>First1</Key>
</TableRow>
<TableRow>
<ID>4</ID>
<ParentID>1</ParentID>
<Key>FirstChild4</Key>
</TableRow>
</ReportBody>
</Table>";
StringReader sReader = new StringReader(XMLReportFormat);
DataSet ds = new DataSet();
if (sReader == null)
return null;
ds.ReadXml(sReader);
在这里我得到列的所有DataType
为String
。 我要像ID
和ParentID
一些列作为Integer
你正在设置这个xml值到一个属性什么的? – Vinicius 2012-03-13 14:10:11
@Vinicius:为什么财产来到现场? ...我没有使用任何属性 – Sreekumar 2012-03-13 14:15:51
因为如果您正在使用属性,您可以尝试将xml属性(例如:ID)的值解析为具有相同名称的属性的类型。 – Vinicius 2012-03-13 14:17:38