6

my question is pretty simple, I've an array of bytes (fullfilled via Sockets) and I would like transform it into a XmlTextReader object. How can I do this?

This doesn't work :

byte[] buffer = new byte[5000]; // TODO a revoir
int sizeReceived;

sizeReceived = _socket.Receive(buffer);
string s = Encoding.UTF8.GetString(buffer, 0, sizeReceived); // s is correctly fulfilled with XML a get back
MemoryStream memory = new MemoryStream(buffer);
memory.Position = 0;

return new XmlTextReader(memory);

Thanks for help.

0

1 Answer 1

7

Set start and end index of stream.

byte[] buffer = new byte[5000]; // TODO a revoir
int sizeReceived;

sizeReceived = _socket.Receive(buffer);
MemoryStream memory = new MemoryStream(buffer, 0, sizeReceived);
return new XmlTextReader(memory);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.