From: Martin Honnen on
Anthony wrote:
> XmlDataDocument xmlDatadoc = new XmlDataDocument();
> xmlDatadoc.DataSet.ReadXml(@"d:\myxmlfile.xml");
> DataSet ds = new DataSet("books");
> ds = xmlDatadoc.DataSet;
> dataGridView1.DataSource = ds.DefaultViewManager;
> dataGridView1.DataMember = "title";

You don't need the XmlDataDocument but you need an XML schema for your
XML document. Visual Studio can generate one for you, of course you
might need to edit schema types to what you want. Then use e.g.
DataSet ds = new DataSet();
ds.ReadXmlSchema("schema.xsd");
ds.ReadXml("file.xml");


--

Martin Honnen --- MVP Data Platform Development
http://msmvps.com/blogs/martin_honnen/
From: Anthony on
> You don't need the XmlDataDocument but you need an XML schema for your XML
> document. Visual Studio can generate one for you, of course you might need
> to edit schema types to what you want. Then use e.g.
> DataSet ds = new DataSet();
> ds.ReadXmlSchema("schema.xsd");
> ds.ReadXml("file.xml");

Works exelent !
What's the best place to save the schema?
If possible i'd like to integrate it with my project.
(i need to parse a xml file from another application. So normally there's no
schema available)

Anthony


From: Anthony on
> You don't need the XmlDataDocument but you need an XML schema for your XML
> document. Visual Studio can generate one for you, of course you might need
> to edit schema types to what you want. Then use e.g.
> DataSet ds = new DataSet();
> ds.ReadXmlSchema("schema.xsd");
> ds.ReadXml("file.xml");

Is it possible to use Linq in the 'same' way ?
(I need a query for some elements)

Anthony


From: Martin Honnen on
Anthony wrote:
>> You don't need the XmlDataDocument but you need an XML schema for your XML
>> document. Visual Studio can generate one for you, of course you might need
>> to edit schema types to what you want. Then use e.g.
>> DataSet ds = new DataSet();
>> ds.ReadXmlSchema("schema.xsd");
>> ds.ReadXml("file.xml");
>
> Is it possible to use Linq in the 'same' way ?
> (I need a query for some elements)

What kind of LINQ do you want to do? There is LINQ to DataSet that
allows you querying your DataSet. There is LINQ to XML that allows
querying an XML document but for that you need to load the XML document
into a System.Xml.Linq.XDocument (or XElement) and there is no
connection between a DataSet and an XDocument.


--

Martin Honnen --- MVP Data Platform Development
http://msmvps.com/blogs/martin_honnen/
From: Anthony on
> What kind of LINQ do you want to do? There is LINQ to DataSet that allows
> you querying your DataSet. There is LINQ to XML that allows querying an
> XML document but for that you need to load the XML document into a
> System.Xml.Linq.XDocument (or XElement) and there is no connection between
> a DataSet and an XDocument.

Don't know what's the best solution. (no experience so far)
I need to make a query (xml file or DataSet) and add the final results to my
DataGrid.
Maybe you can give me some advice ?

Did you read my previous quetion about the schema ?

Anthony



First  |  Prev  |  Next  |  Last
Pages: 1 2 3
Prev: Strange Tooltip Problem
Next: MSIL code