Serialization/Deserialization or XML as DB

Discussion in 'ASP .Net' started by umbertoeklat@yahoo.com, May 11, 2004.

  1. Guest

    as a proof of concept, am trying create a web app w/ an XML file as a
    temp DB

    What is the fastest way to do serialization/deserialization?
    or maybe the better question would be how to efficiently
    retrieve/save data to an xml file.

    have tried deserializing from XML file but having a hard time on
    mulitple records...


    sample codes would be nice :)

    thanks
    , May 11, 2004
    #1
    1. Advertising

  2. The fastest way is to use a dataset. You can use ds.WriteXml and ds.ReadXml
    quite easily.

    Private Sub WriteXmlToFile(thisDataSet As DataSet)
    If thisDataSet Is Nothing Then
    Return
    End If
    ' Create a file name to write to.
    Dim filename As String = "myXmlDoc.xml"
    ' Create the FileStream to write with.
    Dim myFileStream As New System.IO.FileStream _
    (filename, System.IO.FileMode.Create)
    ' Create an XmlTextWriter with the fileStream.
    Dim myXmlWriter As New System.Xml.XmlTextWriter _
    (myFileStream, System.Text.Encoding.Unicode)
    ' Write to the file with the WriteXml method.
    thisDataSet.WriteXml(myXmlWriter)
    myXmlWriter.Close()
    End Sub

    http://msdn.microsoft.com/library/d.../frlrfSystemDataDataSetClassWriteXmlTopic.asp


    <> wrote in message
    news:...
    >
    > as a proof of concept, am trying create a web app w/ an XML file as a
    > temp DB
    >
    > What is the fastest way to do serialization/deserialization?
    > or maybe the better question would be how to efficiently
    > retrieve/save data to an xml file.
    >
    > have tried deserializing from XML file but having a hard time on
    > mulitple records...
    >
    >
    > sample codes would be nice :)
    >
    > thanks
    Ken Cox [Microsoft MVP], May 11, 2004
    #2
    1. Advertising

  3. Hi,
    XML/web service sounds fantastic, but it is truely very very bad from
    the view of performance. As long as you consider your application
    performance, you should never use it under any cases. It is always bad to
    serialize or deserialize a large data in XML format using disk, memory,
    network or whatever. See the article entitled as Performance comparison
    between SocketPro and dotNet remoting at
    http://www.udaparts.com/articles/fastsocketpro.htm

    DON'T USE XML/WEB SERVICE AS LONG AS YOU CONSIDER PERFORMANCE!

    --
    Yuancai (Charlie) Ye

    Fast and securely accessing all of remote data sources anywhere with
    SocketPro using batch/queue, asynchrony and parallel computation

    See 30 well-tested and real OLEDB examples

    RDB, a tool for fast and securely accessing remote databases with dial-up,
    cable, DSL and wireless modems anywhere
    www.udaparts.com


    <> wrote in message
    news:...
    >
    > as a proof of concept, am trying create a web app w/ an XML file as a
    > temp DB
    >
    > What is the fastest way to do serialization/deserialization?
    > or maybe the better question would be how to efficiently
    > retrieve/save data to an xml file.
    >
    > have tried deserializing from XML file but having a hard time on
    > mulitple records...
    >
    >
    > sample codes would be nice :)
    >
    > thanks
    Yuancai \(Charlie\) Ye, May 12, 2004
    #3
  4. Sahil Malik Guest

    Ok first of all, I think we are talking about persistence, not
    serialization.

    Imagine you filling a bucket with a hose. The process of the water moving
    thru the hose is called as serialization, and the filling of the bucket is
    called as "Persistence".

    Anyway, the fastest way to do persistence, I feel is to create a class that
    represents your data. The class is marked [Serializable]. Then use Binary
    formatter to Serialize it to a memory-mapped file. A memory mapped file is
    what in short the OS will take care of persistence, but it stays in RAM, so
    it's ultra fast. (and easy to implement too). Now if this were a web
    application, you could use advanced techniques like caching (asp.net), or
    object pooling (COM interop), to get even better performance benefit. ...
    man this is getting exciting as we go :).

    See - thats the catch, Your proof of concept doesn't need to do XML
    persistence, because Binary would be SO MUCH quicker, and then you could
    obviously set [xmlelement] on each of the class's public properties, to
    convert it to xml using XMLSerialization*.*, which might I add is entirely
    different from BinaryFormatter, and SoapFormatter, and easily within memory
    convert it to XML - should you need it - though once you have represented
    your data as a serializable class - I see no need to involve XML here :).

    - Sahil Malik
    Independent Consultant
    You can reach me thru my blog - http://dotnetjunkies.com/WebLog/sahilmalik/



    <> wrote in message
    news:...
    >
    > as a proof of concept, am trying create a web app w/ an XML file as a
    > temp DB
    >
    > What is the fastest way to do serialization/deserialization?
    > or maybe the better question would be how to efficiently
    > retrieve/save data to an xml file.
    >
    > have tried deserializing from XML file but having a hard time on
    > mulitple records...
    >
    >
    > sample codes would be nice :)
    >
    > thanks
    Sahil Malik, May 14, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?TWlrZSBMb2dhbg==?=

    NameValueCollection Serialization Deserialization

    =?Utf-8?B?TWlrZSBMb2dhbg==?=, Dec 22, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    1,975
    Karl Seguin
    Dec 23, 2004
  2. Nimmi Srivastav
    Replies:
    12
    Views:
    13,441
    EventHelix.com
    May 29, 2004
  3. andrewzzz
    Replies:
    0
    Views:
    378
    andrewzzz
    Dec 12, 2008
  4. andrewzzz
    Replies:
    0
    Views:
    322
    andrewzzz
    Dec 16, 2008
  5. Robert Millman

    Serialization / Deserialization across WebService Calls

    Robert Millman, Feb 5, 2004, in forum: ASP .Net Web Services
    Replies:
    1
    Views:
    99
Loading...

Share This Page