Persisting objects as XML

  • Thread starter Thread starter msnews
  • Start date Start date
M

msnews

Does anyone have an example class for persisting (any) object as XML ?
Similar to the XMLSerializer in the desktop framework I suppose...

i..e

class Invoice
{
string Name;
double Value;
}

and get it to persist as <Invoice Name="Fred" Value="100.00" />
 
You are basically asking for XML Serialization - which has been annoyingly
left out of .NET CF.

See post titled "Where is XMLSerializer in .NET CF" in this newsgroup.

Joe
 
Given your simple example of what's required you may be able to construct
the xml yourself.

Imports System.Reflection
....
Public Sub ShowFields(obj as Object)
For Each fi As FieldInfo In
obj.GetType.GetFields(BindingFlags.Public Or BindingFlags.Instance)
MsgBox(fi.Name & " - " & fi.GetValue(obj))
Next
End Sub
 
Back
Top