Friday, 15 April 2011

windows phone - How to take an xml response received from a web service and make it a datasource -



windows phone - How to take an xml response received from a web service and make it a datasource -

i'm making windows 8.1 phone app , have listbox i'm trying populate data. problem using web service , figured out how info in xml format , don't know how create itemssource listbox. i'm sorry if stupid question first time doing , can't seem find info online.

below simple illustration requests xml document uri on https.

it downloads xml asynchronously string , uses xdocument.parse() load it.

private void button2_click(object sender, routedeventargs e) { webclient wc = new webclient(); wc.downloadstringcompleted += httpscompleted; wc.downloadstringasync(new uri("https://domain/path/file.xml")); } private void httpscompleted(object sender, downloadstringcompletedeventargs e) { if (e.error == null) { xdocument xdoc = xdocument.parse(e.result, loadoptions.none); this.textbox1.text = xdoc.firstnode.tostring(); } }

have on this thread.

hope helps!

windows-phone

No comments:

Post a Comment