Question about Convert XML to DataTable
-
I am programming a movie info collect tool. I think store all data with XML is OK. Here is the MovieDataXML
<?xml version="1.0" encoding="utf-8" ?>
<Data>
<Movie>
<ChineseName>aa</ChineseName>
<EnglishName>aa</EnglishName>
<Year>aa</Year>
<Area>aa</Area>
<Type>aa</Type>
<Language>aa</Language>
<Subtitle>aa</Subtitle>
<IMDB>aa</IMDB>
<Resolution>aa</Resolution>
<Director>aa</Director>
<Actors>aa</Actors>
<Introduction>aa</Introduction>
<BelongTo>aa</BelongTo>
<DiscNumber>aa</DiscNumber>
</Movie>
</Data>And when I try to read the data.
//clsXmlHandler is a class to read the xml data
ClassXMLHandler clsXmlHandler = new ClassXMLHandler();
string strMovieData = "Data";
XmlNode xNodeMovieData = clsXmlHandler.MovieDataDocument.SelectSingleNode(strMovieData);
XmlNodeReader xReader = new XmlNodeReader(xNodeMovieData);Here is the problem If I read XML data by DataTable There will be a Exception "DataTable does not support schema inference from Xml", If I create this DataTable schema manually,there is no data in that DataTable.
DataTable dtMovieData = new DataTable();
dtMovieData.ReadXml(xReader);But I found it is OK if I use DataSet instead of DataTable
DataSet ds = new DataSet();
ds.ReadXml(xReader);I don't know why.