Clayton1234 Posted July 28, 2007 Posted July 28, 2007 :eek: Im trying to view an xml file with a datagrid view, and i get nothing.. I use dialog to get xml path create a dataset dataset.readxml(path) datagridview.datasource = dataset i dont know what else to try. Please help :confused: Quote
techmanbd Posted July 30, 2007 Posted July 30, 2007 Here is a simple one I have. Hopefully this will help for what you are looking for or help to get you going in the right direction. dtaEquip is my datagrid Try Dim strPath As String = AppDomain.CurrentDomain.SetupInformation.ApplicationBase Dim dsEquip As New DataSet dsEquip.ReadXmlSchema(strPath & "HBLabSpec.xsd") dsEquip.ReadXml(strPath & "HBLabDevices.xml") Me.dtaEquip.DataSource = dsEquip.Tables("labdevice") Catch ex As Exception MessageBox.Show(ex.Message, "Data Retrieval Error", MessageBoxButtons.OK, MessageBoxIcon.Error) End Try Here is what my xml file looks like. <?xml version="1.0" standalone="yes"?> <HBLabSpec xmlns="http://tempuri.org/HBLabSpec.xsd"> <LabDevice> <Address>2</Address> <Device>xantrexps</Device> </LabDevice> </HBLabSpec> Quote Live as if you were to die tomorrow. Learn as if you were to live forever. Gandhi
Clayton1234 Posted August 2, 2007 Author Posted August 2, 2007 Would you mind explaining the two things i've quoted? Dim strPath As String = AppDomain.CurrentDomain.SetupInformation.ApplicationBase dsEquip.ReadXmlSchema(strPath & "HBLabSpec.xsd") Thanks Quote
tfowler Posted August 2, 2007 Posted August 2, 2007 The "Dim strPath..." statement gets the path to the directory from which the application is executing (which is obviously where he expects to find his XML data). The "dsEquip.ReadXmlSchema..." statement gets the schema information for the XML file. A schema file describes the structure of an XML file. For instance, when you save a DataSet to an XML file using DataSet.WriteXml, with the XmlWriteMode.WriteSchema option, it will create a schema file for you that defines such things as: which nodes are the tables vs which nodes are the columns, etc. If you do not have a schema file, the DataSet.ReadXml method has to try to figure out the schema from the data. If unsuccessful, you either get an exception, or no data in the DataSet. Todd Quote
techmanbd Posted August 2, 2007 Posted August 2, 2007 Exactly what Todd said. Quote Live as if you were to die tomorrow. Learn as if you were to live forever. Gandhi
Clayton1234 Posted August 3, 2007 Author Posted August 3, 2007 Thanks guys. I'll give it a try. Quote
Clayton1234 Posted August 9, 2007 Author Posted August 9, 2007 (edited) Can someone please help me build a schema for the following xml file??? ___________________________ [highlight=xml] <?xml version="1.0" ?> <records> <image signid="1309AB53-60F0-4678-82AA-F08C030E6E10"> <signtype>Aluminum Sign</signtype> <signtypecustom /> <sizeheight>12</sizeheight> <SizeWidth>16</SizeWidth> <imagename>AAA0001.sef</imagename> <computerid>AAA</computerid> <datetimecreated>8/2/2007</datetimecreated> <datetimesent>12:00:00 AM</datetimesent> <noofcliparts>0</noofcliparts> <noofobjects>2</noofobjects> <isfromexistingart>0</isfromexistingart> <firstname>cndjws</firstname> <middlename>h</middlename> <lastname>fhf</lastname> <billaddress1>66 fggsd g</billaddress1> <billaddress2 /> <billaddresscity>hdfhsh</billaddresscity> <billaddressstate>al</billaddressstate> <billaddresszip>36054</billaddresszip> <shipaddress1>66 fggsd g</shipaddress1> <shipaddress2 /> <shipaddresscity>hdfhsh</shipaddresscity> <shipaddressstate>al</shipaddressstate> <shipaddresszip>36054</shipaddresszip> <billphoneno>3334444444</billphoneno> <shipphoneno>3334444444</shipphoneno> <altphoneno /> <emailaddress>gdfggad@tfsag.com</emailaddress> <ccnumber /> <nameoncc /> <typeofcc /> <ccexpmonth>0</ccexpmonth> <ccexpyear>0</ccexpyear> <isreceiptprinted>0</isreceiptprinted> <processingstatus /> <splinstructions /> <sentattempts>0</sentattempts> <transmitsuccessimg /> <transmitsuccessxml /> <price>20.216</price> <quantity>1</quantity> <tshirtsize /> </image> </records> [/highlight]________________________ Edited August 9, 2007 by PlausiblyDamp Quote
techmanbd Posted August 9, 2007 Posted August 9, 2007 This should be easier than you think actually. When you have your project opened, go to the xml file, right click on the page and scroll down where it says "Create Schema". And voila. Quote Live as if you were to die tomorrow. Learn as if you were to live forever. Gandhi
Clayton1234 Posted August 9, 2007 Author Posted August 9, 2007 This should be easier than you think actually. When you have your project opened, go to the xml file, right click on the page and scroll down where it says "Create Schema". And voila. I tried right clicking on the xml opened file, and i dont see "create schema" Quote
Clayton1234 Posted August 9, 2007 Author Posted August 9, 2007 oops. there's a button instead. Sweet! Thanks Quote
techmanbd Posted August 9, 2007 Posted August 9, 2007 I did a screen shot and attached a gif to see what I was talking about. I think I may know why you didn't see it. When you right clicked, did you do that on the file in the Solution Explorer area? That would not be where you would right click. You need to right click in the opened page, where the xml data is. Look at the pic and you will see what I mean. But at least you found the button. I don't see the button, but I just looked and I don't have the toolbar for xml added. Quote Live as if you were to die tomorrow. Learn as if you were to live forever. Gandhi
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.