I need Some Help

Topics: Developer Forum, Project Management Forum, User Forum
Aug 12, 2011 at 10:12 AM

Hey guys i need some help with the htmlagiltity pack

i got this code and i don't know why it isn't working

there is no error code or something

(this is made in visual studio express mobile)

i loaded my url in with this

teamsite = "http://www.knbsb.nl/nw/index.php?option=com_content&view=category&layout=blog&id=382&Itemid=150&lang=nl&LevelID=120&CompID=1580"

        public static void RequestAsync(Uri url, Action callback)
        {
            if (callback == null)
            {
                throw new ArgumentNullException("callback");
            }

            try
            {
                var req = WebRequest.CreateHttp(url);

                AsyncCallback getTheResponse = ar =>
                {
                    try
                    {
                        string responseString;

                        var request = (HttpWebRequest)ar.AsyncState;

                        using (var resp = (HttpWebResponse)request.EndGetResponse(ar))
                        {
                            using (var streamResponse = resp.GetResponseStream())
                            {
                                using (var streamRead = new StreamReader(streamResponse))
                                {
                                    responseString = streamRead.ReadToEnd();
                                }
                            }
                        }

                        callback(responseString, null);
                    }
                    catch (Exception ex)
                    {
                        callback(null, ex);
                    }
                };

                req.BeginGetResponse(getTheResponse, req);
            }
            catch (Exception ex)
            {
                callback(null, ex);
            }
        }
                RequestAsync(
                new Uri(teamsite),
                (html, exc) =>
                {
                    if (exc == null)
                    {
                        m_doc = new HtmlDocument();
                        Dispatcher.BeginInvoke(() => m_doc.LoadHtml(html));
                        this.SetRanking();
                    }
                    else
                    {
                      
                    }
                });

here is the parsing of the url
        public void SetRanking()
        {
            System.Diagnostics.Debug.WriteLine(m_doc + " " + teamsite);
            string Numhead = "/html/body/div[4]/div/div[4]/div/div/div/div/div/div/div/div/div/div/div/table/thead/tr/th[1]";
            var NumheadResult = m_doc.DocumentNode.SelectNodes((string)Numhead);
            foreach (var item in NumheadResult)
            {
                NumheadBlock.Text = item.Value;
            }


            string Teamhead = "/html/body/div[4]/div/div[4]/div/div/div/div/div/div/div/div/div/div/div/table/thead/tr/th[2]";
            var TeamheadResult = m_doc.DocumentNode.SelectNodes((string)Teamhead);
            foreach (var item in TeamheadResult)
            {
                TeamheadBlock.Text = item.Value;
            }

            string team_first = "/html/body/div[4]/div/div[4]/div/div/div/div/div/div/div/div/div/div/div/table/tbody/tr/td[2]";
            var team_firstResult = m_doc.DocumentNode.SelectNodes((string)team_first);
            foreach (var item in team_firstResult)
            {
                team_firstBlock.Text = item.Value;
            }
        }
i don't get it why it is going wrong,