Hi,
Lets say I have the following XML file.
<Customers id="12345">
<Name>John</Name>
<age>20</age>
<orders type="BUY">
<item>computer#1</item>
</orders>
</Customers>
And I have visual studio generated a xmlSchema for me. Now, I do the following,
Dim ds as new System.data.DataSet
ds.ReadXmlSchema(Server.MapPath("~/file.xsd"))
ds.ReadXml(Server.MapPath("~/file.xml"))
Thanks,
Tanyone?I'm not entirely certain, but I think you should be able to access the data in the dataset by reference. Like this:
Dim ds as new System.data.DataSet
ds.ReadXmlSchema(Server.MapPath("~/file.xsd"))
ds.ReadXml(Server.MapPath("~/file.xml"))
'This may not be correct
txtBox1.Text = ds.tables(0).rows(0).item("Name")
'To learn more about how the dataset is setup try this
Dim Dtg As New Datagrid
Dtg.DataSource = Ds
Dtg.DataBind()
Page.Controls.Add(Dtg)
As for creating a Strong Typed Dataset. What Visual Studio does is allows you to create an XML schema using a Wysiwyg interface. Then, it creates classes which inherit from the Dataset class and represent the XML schema. If you don't have visual studio, then search Microsoft for XSD.exe. I believe this executable can be passed an XML schema and it will generate a strong typed dataset for you.
Good luck.Hi,
Thanks for your reply. I know how to create a strong typed dataset in vs.net...
i was wondering, how do you do it in codebehind manually....
I understand how to bind dataset to a grid controls...but i was wondering how to set something like this....
<customers type="seller">
<name> John Smith</name>
<orders>
<item>item#123</item>
</orders>
</customers>
I understand this will generate 2 tables, customers and orders. and Type will be an atribute of table customers. and item is an element of ordres table, name will be element for customers table... But I dont know how to create that attribute back to the dataset if i have that type in a textbox or soemting...
thx.
tHi
Checkout this link on how to work with dataset's
<!-- m --><a class="postlink" href="http://www.homeandlearn.co.uk/NET/nets12p7.html">http://www.homeandlearn.co.uk/NET/nets12p7.html</a><!-- m -->
and manipulate the dataset instead of xml
when finish with makeing changes then
dim f as file
if f.exists("c:\xmlfile.xml") = true then
f.delete("c:\xmlfile.xml")
end if
Dsmydataset.WriteXml("c:\xmlfile.xml")thanks.
Lets say I have the following XML file.
<Customers id="12345">
<Name>John</Name>
<age>20</age>
<orders type="BUY">
<item>computer#1</item>
</orders>
</Customers>
And I have visual studio generated a xmlSchema for me. Now, I do the following,
Dim ds as new System.data.DataSet
ds.ReadXmlSchema(Server.MapPath("~/file.xsd"))
ds.ReadXml(Server.MapPath("~/file.xml"))
Thanks,
Tanyone?I'm not entirely certain, but I think you should be able to access the data in the dataset by reference. Like this:
Dim ds as new System.data.DataSet
ds.ReadXmlSchema(Server.MapPath("~/file.xsd"))
ds.ReadXml(Server.MapPath("~/file.xml"))
'This may not be correct
txtBox1.Text = ds.tables(0).rows(0).item("Name")
'To learn more about how the dataset is setup try this
Dim Dtg As New Datagrid
Dtg.DataSource = Ds
Dtg.DataBind()
Page.Controls.Add(Dtg)
As for creating a Strong Typed Dataset. What Visual Studio does is allows you to create an XML schema using a Wysiwyg interface. Then, it creates classes which inherit from the Dataset class and represent the XML schema. If you don't have visual studio, then search Microsoft for XSD.exe. I believe this executable can be passed an XML schema and it will generate a strong typed dataset for you.
Good luck.Hi,
Thanks for your reply. I know how to create a strong typed dataset in vs.net...
i was wondering, how do you do it in codebehind manually....
I understand how to bind dataset to a grid controls...but i was wondering how to set something like this....
<customers type="seller">
<name> John Smith</name>
<orders>
<item>item#123</item>
</orders>
</customers>
I understand this will generate 2 tables, customers and orders. and Type will be an atribute of table customers. and item is an element of ordres table, name will be element for customers table... But I dont know how to create that attribute back to the dataset if i have that type in a textbox or soemting...
thx.
tHi
Checkout this link on how to work with dataset's
<!-- m --><a class="postlink" href="http://www.homeandlearn.co.uk/NET/nets12p7.html">http://www.homeandlearn.co.uk/NET/nets12p7.html</a><!-- m -->
and manipulate the dataset instead of xml
when finish with makeing changes then
dim f as file
if f.exists("c:\xmlfile.xml") = true then
f.delete("c:\xmlfile.xml")
end if
Dsmydataset.WriteXml("c:\xmlfile.xml")thanks.