I tried different things?
First try: Here I have this error "Data at the root level is invalid. Line 1, position 1."
StringReader StringStream = new StringReader(strFullPath);
DataSet ds = new DataSet();
ds.ReadXml(StringStream);
Second try:
using (StreamReader mySR = new StreamReader(strFullPath, Encoding.GetEncoding("iso-8859-1") ))
{
XmlDocument lgnXml = new XmlDocument();
lgnXml.Load(mySR); This line has no errors, Only to test....
lrs1.ReadXml(mySR,XmlReadMode.ReadSchema); But in this line I have the error "Root element is missing."
}
Here is the first part of the xml (structure)
<NewDataSet>
<xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:MainDataTable="Table" msdata:UseCurrentLocale="true" msdata:PageSize="0" msdata:CurrentPosition="0" msdata:ConnectionString="" msdata:Sort="" msdata:LoadSchemaOnly="False" msdata:Filter="" msdata:AbsolutePosition="1" msdata:SqlQuery="" msdata:AbsolutePage="0" msdata:Disconnected="False">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="Table">
<xs:complexType>
<xs:sequence>
<xs:element name="LanguageID" type="xs:int" minOccurs="0" />
<xs:element name="Compania" type="xs:string" minOccurs="0" />
<xs:element name="Facilidad" type="xs:string" minOccurs="0" />
<xs:element name="Cuenta" type="xs:string" minOccurs="0" />
<xs:element name="Numero" type="xs:string" minOccurs="0" />
And the data
<Table>
<LanguageID>2</LanguageID>
<Compania>Company</Compania>
<Facilidad>Facility</Facilidad>
<Cuenta>Account</Cuenta>
<Numero>Number</Numero>
<Nombre>Name</Nombre>
There are more many fields...
Thanks, Jose
Your first try only works if you put the XML in the StringReader constructor:
You second sample should work if you leave out your test line
because that will line will read the stream till the end. The method
lrs1.ReadXml(
has then no more characters to process hence the error.