TypedView -> XML

Posts   
 
    
mattc58
User
Posts: 7
Joined: 19-Nov-2004
# Posted on: 22-Dec-2004 16:34:02   

Howdy,

What is the best way to take a populated TypedView class and serialize it to XML?

The following works fine if you've got a typed DataSet which matches the view:


        Dim objDS As New Inventory_TieredPricing
        For Each objRow As DataRow In objV.Rows
            objDS.Inventory_TieredPrice.ImportRow(objRow)
        Next
        objDoc.InnerXml = objDS.GetXml()
        Return objDoc

However, I'd much rather have code like this:


  objDoc.InnerXML = objV.ToXml()

That ToXml() method would simply take what was in the typed view and turn it into an XML structure like:

<ViewName> <Column1>value</Column1> <Column2>value</Column2> etc </ViewName>

I can do this with programming pretty easily, but I waiting to see if it already existing before I did it.

Thanks for any help,

Matt

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39910
Joined: 17-Aug-2003
# Posted on: 22-Dec-2004 17:53:34   

A typed view is a datatable, so the easy way out is to add it to a dataset and then use the dataset's WriteXml() routine to get the xml simple_smile

Frans Bouma | Lead developer LLBLGen Pro
mattc58
User
Posts: 7
Joined: 19-Nov-2004
# Posted on: 22-Dec-2004 19:01:49   

Otis wrote:

A typed view is a datatable, so the easy way out is to add it to a dataset and then use the dataset's WriteXml() routine to get the xml simple_smile

I did not notice this until you mentioned it. Sure enough this works well. Thanks!

Anthony
User
Posts: 155
Joined: 04-Oct-2006
# Posted on: 05-Oct-2007 03:10:46   
    Dim oNotes As New VwCallsTypedView()
    Dim adapter As New DataAccessAdapter()

    Dim sNotesXML As String = String.Empty
    Try

        adapter.FetchTypedView(oNotes.GetFieldsInfo(), oNotes)
        oNotes.WriteXml(System.AppDomain.CurrentDomain.BaseDirectory() & "xml.xml")

.....

Why does the output include crlf characters...this causes issues with readxml.

Writexml on an entity does not produce this issue..hope someone can help.

Anthony

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 05-Oct-2007 11:40:46   

Do you get the same issue serializing a simple DataTable?