Bha Sngh

Bha Sngh

  • NA
  • 1
  • 1.4k

How to load XMl data from Web API into Listview.

Sep 30 2013 5:28 PM
The webAPI is not providing any asmx file .

I am using one button and listview and text box.

In Textbox we put the name of the city.

OnClick Button event will load all the xml data into listview.

Since the webAPI is not providing any asmx file,  we cannot use reference in asp.net.

my code is as follows:

XmlDocument xdoc = new XmlDocument();//xml doc used for xml parsing

        xdoc.Load(
            "http://api.indeed.com/ads/apisearch?publisher=***************&q=java&l=fremont%2C+ca&sort=&radius=&st=&jt=&start=&limit=&fromage=&filter=&latlong=1&co=us&chnl=&userip=1.2.3.4&useragent=Mozilla/%2F4.0%28Firefox%29&v=2"
            );//loading XML in xml doc

        XmlNodeList xNodelst = xdoc.DocumentElement.SelectNodes("results/result");//reading node so that we can traverse thorugh the XML


        DataTable jobTable = new DataTable();
       jobTable.ReadXmlSchema("xNodelst");
        jobTable.ReadXml("xNodelst");
        ListView1.DataSource = jobTable;
        ListView1.DataBind();
        foreach (ListViewItem lvi in ListView1.Items)
        {
          
          //  what to put here...????
        }
    }


Thanks