I am connecting to a web service to get some data as xml. The connection works fine and returns xml data from the service.
var remoteURL = EveApiUrl;
var postData = string.Format("userID={0}&apikey={1}&characterID={2}", UserId, ApiKey, CharacterId);
var request = (HttpWebRequest)WebRequest.Create(remoteURL);
request.Method = "POST";
request.ContentLength = postData.Length;
request.ContentType = "application/x-www-form-urlencoded";
var WebEncoding = new ASCIIEncoding();
var byte1 = WebEncoding.GetBytes(postData);
var newStream = request.GetRequestStream();
newStream.Write(byte1, 0, byte1.Length);
newStream.Close();
var response = (HttpWebResponse)request.GetResponse();
var receiveStream = response.GetResponseStream();
var readStream = new StreamReader(receiveStream, Encoding.UTF8);
var webdata = readStream.ReadToEnd();
Console.WriteLine(webdata);
Submits the xml that comes from the service. I can also save xml as xml file, for example:
TextWriter writer = new StreamWriter(@"C:\Projects\TrainingSkills.xml");
writer.WriteLine(webdata);
writer.Close();
Now I can upload the file as an XDocument to execute requests on it as follows:
var data = XDocument.Load(@"C:\Projects\TrainingSkills.xml");
What is my problem: I do not want to save the file and then upload it again. When I try to load directly from the stream, I get an exception, Invalid characters in the path . I do not know what happens if I can load the same xml as a text file, so I cannot load it as a stream.
xml is as follows:
<?xml version='1.0' encoding='UTF-8'?>
<eveapi version="2">
<currentTime>2010-04-28 17:58:27</currentTime>
<result>
<currentTQTime offset="1">2010-04-28 17:58:28</currentTQTime>
<trainingEndTime>2010-04-29 02:48:59</trainingEndTime>
<trainingStartTime>2010-04-28 00:56:42</trainingStartTime>
<trainingTypeID>3386</trainingTypeID>
<trainingStartSP>8000</trainingStartSP>
<trainingDestinationSP>45255</trainingDestinationSP>
<trainingToLevel>4</trainingToLevel>
<skillInTraining>1</skillInTraining>
</result>
<cachedUntil>2010-04-28 18:58:27</cachedUntil>
</eveapi>
Thank you for your help!