tags:

views:

28

answers:

1

Do educate me about XML, I feel like a total dunce.

I'm supposed to send XML in a POST header and there's a library with method that takes a string contentType and a System.IO.Stream body.

How?

I suppose the first parameter is "text/html; charset=utf-8" which limits the type of stream used.

Bonus question: What's the easiest way of creating your XmlDocument? What type of structure do you usually aim to start of with?

Btw the library is the OAuth package from Madgex.

'Preciate it!

+2  A: 

You should use System.Xml.Linq.dll.

For example:

var document = new XDocument(new XElement("Root", new XAttribute("Attr", "Value")));
var stream = new MemoryStream();
document.Save(stream);
stream.Position = 0;   //Important!

SomeMethod("text/xml", stream);

Note that this requires C# 3.0.

SLaks
Thank you! It's immediately clear how this will work out beautifully.
Martin