I write this code block on my windows 8.1 project it's working. But didn't work on my windows phone 8.1 project
private void Page_Loaded(object sender, RoutedEventArgs e)
{
Uri url = new Uri("http://www.tcmb.gov.tr/kurlar/today.xml");
XDocument xml = XDocument.Load(url.ToString());
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(xml.ToString());
}
First of all, I downloaded the XML and Windows Phone doesn't support "ISO-8859-9".
Second, in order to use XDocument, you need to download the file and send the stream as a parameter to the Load method.
Here's an example:
public void LoadXML()
{
HttpClient client = new HttpClient();
var httpResponseMessage = await client.GetAsync(new Uri("http://thewindev.net/post-sitemap.xml"));
if (httpResponseMessage.StatusCode == HttpStatusCode.OK)
{
var xmlStream = await httpResponseMessage.Content.ReadAsStreamAsync();
XDocument xml = XDocument.Load(xmlStream);
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(xml.ToString());
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.