I have some classes that I have configured for XML serialization. I have
been able to write the files to the hard drive and then load them in and
transform them into the HTML that I want. What I would like to do is skip
the file on the hard drive and serialize the class directly to an
XPathDocument or something that I can use to create this document. Does
anyone have any thoughts on this?
With VB 9 is there a better way to take data stored in a class and convert
it into HTML for reporting?
What is the preferred way to link an XML Schema to my classes that store the
data?
> I have some classes that I have configured for XML serialization. I have
> been able to write the files to the hard drive and then load them in and
> transform them into the HTML that I want. What I would like to do is skip
> the file on the hard drive and serialize the class directly to an
> XPathDocument or something that I can use to create this document. Does
> anyone have any thoughts on this?
You can serialize to an XmlDocument like this
Dim serializer As New XmlSerializer(GetType(Foo))
Dim f As New Foo()
f.Bar = "foobar"
Dim doc As New XmlDocument()
Using writer As XmlWriter = doc.CreateNavigator().AppendChild()
serializer.Serialize(writer, f)
End Using
and then pass that XmlDocument to the Transform method (for the
overloads that take an IXPathNavigable):
Dim xsltProcessor As New XslCompiledTransform()
xsltProcessor.Load("sheet.xml")
xsltProcessor.Transform(doc, Nothing, Console.Out)
> With VB 9 is there a better way to take data stored in a class and convert
> it into HTML for reporting?
There is an ObjectXPathNavigator
<URL:http://msdn2.microsoft.com/en-us/library/ms950764.aspx> but I am
not sure it works with current .NET versions.
> What is the preferred way to link an XML Schema to my classes that store the
> data?
What exactly do you want to achieve by "linking" a schema to classes?

Signature
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Brad Overstreet - 24 Feb 2008 23:51 GMT
Sorry it took me so long to get back to this. The method you provided worked
and allowed me to keep the serialization and transformation completely in
memory.
The class linking is probably not the right way to describe what I was
refering to. What I was wanting was to fully define the data using a schema
and then use that schema to construct the classes in VB .NET to work with the
data. I have seen a few references to xsd.exe in the newsgroups but I have
not explored it yet.
A lot of the data I need to work with will not ever be stored in a database
that visual studio can relate to. This is why I am interested in using
schemas, classes and transforms. This will allow me to strictly control the
creation of the data and provide consistent methods to report on it and
output it for use with the other system (accounting software written in
business basic from BASIS).
> > I have some classes that I have configured for XML serialization. I have
> > been able to write the files to the hard drive and then load them in and
[quoted text clipped - 32 lines]
>
> What exactly do you want to achieve by "linking" a schema to classes?