Problem with loading a xml to DataSet
-
Hi all, I've xml string and I can load it with XmlDataDocument.LoadXml successfully, so that OuterXml shows the real xml string. But when I want to load in a dataset, the result dataset has no table(Tables.Count=0). Typical code is as follows: ... XmlDataDocument Doc = new XmlDataDocument(); /* string Str = "<Result><DN>22800661</DN><ID>1</ID><Status><Line>Idle</Line></Status></Result>"; */ Doc.LoadXml(Str); DataSet datasetResult = Doc.DataSet; if(datasetResult.Tables.Count == 0) return; ... and it returns that means datasetResult.Tables.Count is always 0. Can anyone help me, what is wrong? Thanks in advance
-
Hi all, I've xml string and I can load it with XmlDataDocument.LoadXml successfully, so that OuterXml shows the real xml string. But when I want to load in a dataset, the result dataset has no table(Tables.Count=0). Typical code is as follows: ... XmlDataDocument Doc = new XmlDataDocument(); /* string Str = "<Result><DN>22800661</DN><ID>1</ID><Status><Line>Idle</Line></Status></Result>"; */ Doc.LoadXml(Str); DataSet datasetResult = Doc.DataSet; if(datasetResult.Tables.Count == 0) return; ... and it returns that means datasetResult.Tables.Count is always 0. Can anyone help me, what is wrong? Thanks in advance
Maybe this is what you want ? string Str = "228006611Idle"; System.IO.StringReader sr = new System.IO.StringReader(Str); XmlDataDocument Doc = new XmlDataDocument(); Doc.DataSet.ReadXml(sr); DataSet datasetResult = Doc.DataSet; if (datasetResult.Tables.Count == 0) return;