J
jcvoon
Hi:
I use the following code to copy the contents of the XMLDocument to
byte array
Dim xmlDoc as New XMLDocument
Dim stream As New MemoryStream
Dim buffers() As Byte
xmlDoc.Load("Sample.xml")
xmlDoc.Save(stream)
buffers = New Byte(CInt(stream.Length + 24)) {}
' First 25 Byte is reserve for special purposes
stream.ToArray.CopyTo(buffers, 25)
I want to optimise the code to avoid to use the MemoryStream
Dim xmlDoc as New XMLDocument
Dim buffers() As Byte
xmlDoc.Load("Sample.xml")
buffers = New Byte(CInt(xmlDoc.outerXML + 24)) {}
' First 25 Byte is reserve for special purposes
ASCIIEncoding.ASCII.GetBytes(xmlDoc.outerXML).CopyTo(buffers, 25)
But the result is not same, when i save the buffer contents to file,
the 1st method is same as the input xml file (Sample.xml), but the 2nd
method will result in xml with smaller file size, all white space has
been removed.
Any idea ?
JCVoon
I use the following code to copy the contents of the XMLDocument to
byte array
Dim xmlDoc as New XMLDocument
Dim stream As New MemoryStream
Dim buffers() As Byte
xmlDoc.Load("Sample.xml")
xmlDoc.Save(stream)
buffers = New Byte(CInt(stream.Length + 24)) {}
' First 25 Byte is reserve for special purposes
stream.ToArray.CopyTo(buffers, 25)
I want to optimise the code to avoid to use the MemoryStream
Dim xmlDoc as New XMLDocument
Dim buffers() As Byte
xmlDoc.Load("Sample.xml")
buffers = New Byte(CInt(xmlDoc.outerXML + 24)) {}
' First 25 Byte is reserve for special purposes
ASCIIEncoding.ASCII.GetBytes(xmlDoc.outerXML).CopyTo(buffers, 25)
But the result is not same, when i save the buffer contents to file,
the 1st method is same as the input xml file (Sample.xml), but the 2nd
method will result in xml with smaller file size, all white space has
been removed.
Any idea ?
JCVoon