XmlDocument thread for POST

Inform me about XML, I feel like a complete dunce.

I have to send the XML to the POST header and there is a library with a method that accepts the string contentType and the body of System.IO.Stream.

How?

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

Bonus question: what is the easiest way to create an XmlDocument? What structure do you usually aim to start with?

The btw library is Madgex's OAuth package.

'Mark it!

+3
source share
1 answer

You should use System.Xml.Linq.dll .

For instance:

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);

Please note that this requires C # 3.0.

+2
source

Source: https://habr.com/ru/post/1734160/


All Articles