XML 转换 DataSet 遇到了问题,坐等指点。。。。
<DATA>
<User>
<Name>a</Name>
<City>beijing</City>
<Email>aass@22.net</Email>
<Major>
<majorID>1</majorID>
<majorName>ssdf</majorName>
</Major>
</User>
<User>
<Name>b</Name>
<City>shanghai</City>
<Email>ssdfs@22.net</Email>
<Major>
<majorID>2</majorID>
<majorName>xxdf</majorName>
</Major>
</User>
<User>
<Name>c</Name>
<City>nanjing</City>
<Email>sdss@22.net</Email>
<Major></Major>
</User>
</DATA>
当使用如下代码进行转换后,不知道该如何获取Major 嵌套的记录了:
public static DataSet ConstructResultDS(string strCSOSDataXML)
{
DataSet dsCSOSData = new DataSet();
StringReader srStream = new StringReader(strCSOSDataXML);
XmlTextReader xtrReader = new XmlTextReader(srStream);
try
{
dsCSOSData.ReadXml(xtrReader);
return dsCSOSData;
}
catch (Exception ex)
{
string strTest = ex.Message;
return null;
}
finally
{
if (xtrReader != null)
xtrReader.Close();
}
}
dataset
xml
------解决方案--------------------dsCSOSData["Major"]就是Major的信息
dsCSOSData["User"]就是User的信息&nb