Converting access data to XML

P

Parasyke

Thanks in advance. I'm new to XML. I need to convert an existing Access

table into XML which will allow me on a form to read the table into
XML, edit, then reconvert it back to the Access table. I have
successfully added the Northwind database to my data sources in Visual
Studio 2003 (Standard Edition). I also have the following code which
reads from an EXISTING XML file not related to the Access file. How
could I alter it to pull from Access? Below is the read and Write SUBS
for the existing XML:

Private Sub btnLoadXml_Click(ByVal sender As System.Object, ByVal e



As System.EventArgs) Handles btnLoadXml.Click
Dim xtr As XmlTextReader = _
New XmlTextReader("C:\Documents and Settings\dcampbe\My
Documents\Visual Studio 2005\Projects\310C02\310C02\Books.xml")
xdd = New XmlDataDocument()
ds = xdd.DataSet()
ds.ReadXmlSchema(xtr)
xtr.Close()
xtr = New XmlTextReader("C:\Documents and Settings\dcampbe\My
Documents\Visual Studio 2005\Projects\310C02\310C02\Books.xml")
xtr.WhitespaceHandling = WhitespaceHandling.None
xdd.Load(xtr)
dgXML.DataSource = ds
dgXML.DataMember = "Book"
xtr.Close()
End Sub


Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As



System.EventArgs) Handles btnSave.Click
Dim xtw As XmlTextWriter = New XmlTextWriter("C:\Documents and
Settings\dcampbe\My Documents\Visual Studio
2005\Projects\310C02\310C02\Books.xml", System.Text.Encoding.UTF8)
xtw.Formatting = Formatting.Indented
xdd.WriteTo(xtw)
'Clean up
xtw.Close()
MessageBox.Show("The XML file has been successfully updated !")



End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top