Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / XML / February 2008

Tip: Looking for answers? Try searching our database.

Serializing and transforming data in a class

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Brad Overstreet - 20 Feb 2008 05:53 GMT
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?
Martin Honnen - 20 Feb 2008 12:43 GMT
> 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?

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.