Document Class as XML?

  • Thread starter Thread starter Lars Netzel
  • Start date Start date
L

Lars Netzel

Hello!

I have written a few Classes and inheriting Classes in VB and I would like
to export these as XML...

Is there any programs or maybe even features in Visual Studio to produce
this?

The reason is that the classes are to be populated thru XML files (that I
recieve from another company) in runtime and I need to create the XML schema
and give to the the company so they know how to send the information to
me...

best regards
/Lars
 
I dunno if i'm on the right track here as I've never used classes to xml.
However, it's data so like any other form of data so I have always defined
my schema, loaded it and fed the structure into a datas et through
ReadXMLSchema & XML Text Reader as follows:

Dim fs As FileStream = New FileStream(fileName, FileMode.Open,
FileAccess.Read)
Dim xtr As XmlTextReader = New XmlTextReader(fs)
dsSettings = New DataSet
Try
dsSettings.ReadXmlSchema(xtr)
Catch ex As XmlException
MessageBox.Show(ex.ToString)
End Try

xtr.Close()

Then... loaded the XML file with data(in your case your class has the data)
with...

If File.Exists(SettingsFileName) Then
Dim fsXML As FileStream = New FileStream(SettingsFileName,
FileMode.Open, FileAccess.ReadWrite)
Dim xtrXML As XmlTextReader = New XmlTextReader(fsXML)
dsSettings.ReadXml(xtrXML)
xtrXML.Close()
Else
Return -1
End If

And used a getData function like:

Private Function GetSettings()

Dim tbl As DataTable = dsSettings.Tables("Settings")
If tbl.Rows.Count > 0 Then
Dim row As DataRow = tbl.Rows(0)
XMLData1 = row("data1")
XMLData2 = row("data2")....etc
Else
Return -1
End If

End Function

hope this helps
 

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

Back
Top