Parse XML null reference exception error? C# ASP

Top Serv

New Member
I am super stuck on a simple api usage for over a week now. Here are the details.Trying to make an api call to ebay.com.Here is what my code looks like...This is the starting pages code:\[code\] protected void Button1_Click(object sender, EventArgs e) { Response.Redirect("Results.aspx?Keywords=" + searchString.Text); }\[/code\]The page is directed to this bit of code:\[code\]if (Request.QueryString["Keywords"] != null){ string keywords = Request.QueryString["Keywords"]; string myAppID = "HIDDEN"; var xml = XDocument.Load("http://svcs.ebay.com/services/search/FindingService/v1?OPERATION-NAME=findItemsByKeywords&SERVICE-VERSION=1.0.0&SECURITY-APPNAME=" + myAppID + "&RESPONSE-DATA-FORMAT=XML&REST-PAYLOAD&keywords=" + keywords + "&paginationInput.entriesPerPage=5"); XNamespace ns = "http://www.ebay.com/marketplace/search/v1/services"; var titles = from item in xml.Root.Descendants(ns + "title") select new{ title = xml.Descendants(ns + "title").Select (x => x.Value), }; foreach (var item in titles){ Label1.Text += item; } }\[/code\]Here is the xml example:\[code\]<findItemsByKeywordsResponse xmlns="http://www.ebay.com/marketplace/search/v1/services"><searchReslut count="5"><item> <title></title></item><item> <title></title></item><item> <title></title></item>\[/code\]I really rather turn the items into an array not just list them out. Just thought I would try the easier approach first. Error I get is:The for loop output to my label looks like this:\[code\]{ title = System.Linq.Enumerable+WhereSelectEnumerableIterator`2[System.Xml.Linq.XElement,System.String] }{ title = System.Linq.Enumerable+WhereSelectEnumerableIterator`2[System.Xml.Linq.XElement,System.String] }{ title = System.Linq.Enumerable+WhereSelectEnumerableIterator`2[System.Xml.Linq.XElement,System.String] }{ title = System.Linq.Enumerable+WhereSelectEnumerableIterator`2[System.Xml.Linq.XElement,System.String] }{ title = System.Linq.Enumerable+WhereSelectEnumerableIterator`2[System.Xml.Linq.XElement,System.String] }\[/code\]And the output exception is:A first chance exception of type 'System.Threading.ThreadAbortException' occurred in mscorlib.dllAn exception of type 'System.Threading.ThreadAbortException' occurred in mscorlib.dll but was not handled in user codeThe thread '' (0x27ee4) has exited with code 0 (0x0).Any help is appreciated!
 
Back
Top