XML Deserializing Line Feeds

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • dk9

    XML Deserializing Line Feeds

    I've serialize an object like this:

    Dim MyName As String = "testing" & vbNewLine & "serializat ion"
    Dim Formatter As New Xml.Serializati on.XmlSerialize r(MyName)

    Try
    Dim fs As New FileStream(_Fil ePath, FileMode.Create )
    Formatter.Seria lize(fs, MyName)
    fs.Close()
    Catch ex As Exception

    End Try



    The created XML file is well writen, there's a line feed there.
    But when I'm deserializing the object, the line just dissapears...
    It returns "testingseriali zation"


    Dim Formatter As New
    Xml.Serializati on.XmlSerialize r(GetType(Strin g))

    Try
    Dim fs As New FileStream(_Fil ePath, FileMode.Create )
    Formatter.Seria lize(fs, MyName)
    fs.Close()
    Catch ex As Exception

    End Try


    What's going on here?!??!?!

  • =?Utf-8?B?ZG90TmV0RGF2ZQ==?=

    #2
    RE: XML Deserializing Line Feeds

    If you are just trying to serilize text to something acceptable for xml why
    don't you use System.Web.Http Utility.HtmlEnc ode("some Text")

    David

    =============== =============== ========
    David McCarter [Microsoft MVP]

    David McCarter''''s .NET Coding Standards available at:



    "dk9" wrote:
    I've serialize an object like this:
    >
    Dim MyName As String = "testing" & vbNewLine & "serializat ion"
    Dim Formatter As New Xml.Serializati on.XmlSerialize r(MyName)
    >
    Try
    Dim fs As New FileStream(_Fil ePath, FileMode.Create )
    Formatter.Seria lize(fs, MyName)
    fs.Close()
    Catch ex As Exception
    >
    End Try
    >
    >
    >
    The created XML file is well writen, there's a line feed there.
    But when I'm deserializing the object, the line just dissapears...
    It returns "testingseriali zation"
    >
    >
    Dim Formatter As New
    Xml.Serializati on.XmlSerialize r(GetType(Strin g))
    >
    Try
    Dim fs As New FileStream(_Fil ePath, FileMode.Create )
    Formatter.Seria lize(fs, MyName)
    fs.Close()
    Catch ex As Exception
    >
    End Try
    >
    >
    What's going on here?!??!?!
    >
    >

    Comment

    Working...