473,503 Members | 1,813 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Copy contents of XMLDocument to byte array

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).Copy To(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

Jun 17 '06 #1
0 2342

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2705
by: TDH | last post by:
Hi, I need to do a raw copy of a byte array to an Int16 array. For e.g., I have an byte array which has length 100, and I need to copy this to an Int16 array that has length 50. So 2 elements...
4
8775
by: Simon Schaap | last post by:
Hello, I have encountered a strange problem and I hope you can help me to understand it. What I want to do is to pass an array of chars to a function that will split it up (on every location where...
15
435
by: Kueishiong Tu | last post by:
How do I copy the content of a string in one encoding (in my case big5) to a char array (unmanaged) of the same encoding? I try the following String line = S"123æ°´æ³¥"; char buffer; ...
4
1438
by: Web Team | last post by:
Hi All, I'm trying to update the contents of an XML node. My original code: Dim loXMLDoc As XmlDocument = New XmlDocument Dim loNode As XmlNode...
4
2930
by: Lance | last post by:
I have an array of bytes that I need to convert into an array of Integers. But, the number of bits per value in the Byte array is not necessarily divisible by 8 (although it will never exceed...
7
11600
by: lgbjr | last post by:
Hello All, I¡¯m using a context menu associated with some pictureboxes to provide copy/paste functionality. Copying the image to the clipboard was easy. But pasting an image from the clipboard...
3
12776
by: marfi95 | last post by:
Hi all. I need to copy a byte array into a string, but starting at a specific location in the byte array. This is where I get hung up. For example if my byte array is (100) big, I might want to...
6
72852
by: =?Utf-8?B?U3VzaGlTZWFu?= | last post by:
Hello. How I can copy one byte array to other byte array? For example I have byte array1 = new byte; byte array2 = new byte; in array1 I have useful data from position 55 to 105 and I need...
2
12704
by: TonyJ | last post by:
Hello! Now to my question. Here I copy from a byte array into another byte array and then convert to a string. Is it possible to convert some part from a byte array into a string directly...
0
7202
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7086
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7280
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7460
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5578
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5014
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3167
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1512
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
380
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.