Reputation: 27
I'm new to Windows Phone programming, I was trying to make a search query for e.g. http://www.flipkart.com/search/a/computers?query=ipad+3
I'm doing this with the help of webclient using downloadStringAsync function. Now to retrieve the results back from all my searches I have found that it must be a XML document but how to know it's descendants, children, properties, etc., that I'm not able to figure out.
Is the method I'm trying to use wrong or is there any other way I can make this kind of search query in Windows phone?
An example would be appreciated the most.
I have to populate the data back to listbox.
Hey i finally tried htmlAgilityPack seems it's working till now, but i'm getting a null reference while searching. Please help out with this one.
private void getPage()
{
var wc = new WebClient();
wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wc_DownloadStringCompleted);
wc.DownloadStringAsync(new Uri("http://www.flipkart.com/search-tablets?query=ipad+3"));
}
void wc_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
HtmlAgilityPack.HtmlDocument html = new HtmlAgilityPack.HtmlDocument();
html.OptionFixNestedTags = true;
html.LoadHtml(e.Result);
var doc = html.DocumentNode.Descendants("div").FirstOrDefault(x => x.Id == "line price-cont");
String abc = doc.InnerText;
}
The html version do contain this kind of tag here is the copied part i want to fetch from the page
<div>
<div class="line price-cont ">
<div class='fk-price line'><span class="price final-price">Rs. 32900</span></div>
</div>
i tried searching for span tag also still it returns null. Any kind of help will be appreciated. Thanks
Upvotes: 1
Views: 133
Reputation: 70162
It sounds like you are using the right approach. To parse the XML, I would suggest using Linq-to-XML. You will find loads of tutorials on this topic, including this one which is for Windows Phone specifically.
Give it a go, and if you get stuck, as a more specific question in Stack Overflow, including your code.
Upvotes: 1