?
Solved

HTMLAgilitypack

Posted on 2014-01-30
9
Medium Priority
?
373 Views
Last Modified: 2014-02-02
Hello all,

Im new to using the HTML agaility pack and could do with some help...

currently i can loop though all divs with the class and display the data.... this works great and code is below

Dim webGet As New HtmlWeb() 'open the system
        Dim htmlDoc As HtmlDocument = webGet.Load("http://www.site.com")'' get the html from the webpage

      

		For Each div As Object In htmlDoc.DocumentNode.SelectNodes("//div[@class='matches']")' select all the divs within the code that contain matches

		lblHTMLOutput.Text += div.InnerText & "<br>"

        Next

Open in new window


Now i onyl want to display certain things within those divs.... currently a line would look like this

x KUW D1 Kuwait League 43 14:55 01/30/2014 14:55 GMT 01/30/2014 14:55 Al-Jahra 0 1 - 0 Yarmouk 0


but i want it to just show   Al-Jahra  1 - 0 Yarmouk

to do this i need to display it like this

For Each div As Object In htmlDoc.DocumentNode.SelectNodes("//div[@class='matches']")' select all the divs within the code that contain matches

            lblHTMLOutput.Text += <td class="home"><td> <td class="score"><td>

        Next


I need to display the class home and class score separate as i want to gather information  from them and want to keep it so its looping through the div[@class='matches']


Any help would be grate
0
Comment
Question by:runnerjp2005
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 19

Expert Comment

by:Ken Butters
ID: 39821144
Once you have the "Div" node inside your for loop, you can extract just the td nodes in question... something like this:

Div.selectSingleNode("./td[class='home']")
Div.selectSinglenode("./td[class='score']")
0
 

Author Comment

by:runnerjp2005
ID: 39821171
I tried this but it didnt work....

Dim webGet As New HtmlWeb() 'open the system
        Dim htmlDoc As HtmlDocument = webGet.Load("http://www.site.com")'' get the html from the webpage

      

		For Each div As Object In htmlDoc.DocumentNode.SelectNodes("//div[@class='matches']")' select all the divs within the code that contain *

		lblHTMLOutput.Text += Div.selectSingleNode("//td[@class='score']")

        Next

Open in new window

0
 
LVL 19

Expert Comment

by:Ken Butters
ID: 39821185
the result of the selectSingleNode is a node.  If you want to append the text of that node... You need to specify innerText like you did the original node.

so you'd end up with something like this:

lblHTMLOutput.Text += Div.selectSingleNode("./td[@class='score']").innerText

Also I'd use "./" instead of "//".

"//" is an Xpath directive to search the entire document.

"./" means to start your search within the current node....
0
AWS Certified Solutions Architect - Associate

This course has been developed to provide you with the requisite knowledge to not only pass the AWS CSA certification exam but also gain the hands-on experience required to become a qualified AWS Solutions architect working in a real-world environment.

 

Author Comment

by:runnerjp2005
ID: 39821258
lblHTMLOutput.Text +=  Div.selectSingleNode("./td[@class='score']").innerText

i get the error : System.NullReferenceException: Object variable or With block variable not set.
0
 
LVL 19

Expert Comment

by:Ken Butters
ID: 39821336
That means you ran into a situation where Div.selectSingleNode("./td[@class='score']") did not find a node and ended up being null...

you can check for that with something like this:

Dim htmlDoc As HtmlDocument = webGet.Load("http://www.site.com")
For Each div In htmlDoc.DocumentNode.SelectNodes("//div[@class='matches']")

    var node =  Div.selectSingleNode("./td[@class='score']")
    if (node != null)
		  lblHTMLOutput.Text += Node.InnerText
    end if
Next

Open in new window



whoops... appended this comment to change "//" to "./" again.
0
 

Author Comment

by:runnerjp2005
ID: 39821383
Score is there thouhgh as i can see it...

<div id="matches">

    <div style="display:block" class="matches" id="matcheshd">
            <a id="lnkCount" href="javascript:;">11 Matches</a>
            <a id="lnkHidden" href="javascript:;">Show Hidden (<span id="hRows">0</span>)</a>
            <a id="btnAudio" href="javascript:;"></a>
            <a id="btnTextSize" href="javascript:;"></a>
    </div>
            <div class="league-header">
                <table cellpadding="0" cellspacing="0">
                    <tr>
                        <td>
                            <img src='/content/images/flags/46.png' alt=''/>
                            <span>International - Club Friendly</span>
                        </td>
                    </tr>
                </table>
            </div>
            <div id="1084527" style="display:block" class="matches">
                <table cellpadding="0" cellspacing="0">
                    <tr>
                        <td class="Ma_A flag">
                            <a href="javascript:;" class="x">x</a> 
                            <span id="ln-1084527" style="position:relative;">INT CF
                                <span class="lfname">Club Friendly</span>
                            </span>
                            <input type="hidden" value="2" id="sts-1084527" />
                        </td>
                        <td class="time"> 
HT                                    <span class="kickoff">13:30</span>
                                <span class="date datetimezone">01/30/2014 13:30 GMT</span>
                                <span class="gmtdatetime" style="display:none">01/30/2014 13:30</span>
                        </td>
                        <td class="home">
                             <span id="hg-1084527">
                            </span>
                            <span id="hn-1084527">Kecskemeti TE</span>
                            <span class="card" id="hc-1084527">0</span>
                        </td>
                        <td class="score">
                        
                                <a href="javascript:;" class="scorelink score" matchid="1084527" leaguetitle="Club Friendly" date="1/30/2014 1:30:00 PM">
                                <span id="hs-1084527">0</span> - 
                                <span id="as-1084527">0</span><br />
                                </a>
                        </td>
                        <td class="away">
                            <span id="an-1084527">Szolnoki MAV FC</span>
                            <span id="ag-1084527">
                            </span>
                            <span class="card" id="ac-1084527">0</span>
                        </td>
                        <td id="live-1084527" class="liveicon"></td>
                        <td class="icons">
                            <a href="/Video/1084527" class="video" title="highlights" style="visibility:hidden"></a>
                            <a id="mm-1084527" class="gccmymatch " href="javascript:;"></a>
                            <a id="setting-1084527" class="sicon" href="javascript:;" title="Pick your own sound"></a>
                        </td>
                    </tr>
                </table>
            </div>
            <div id="1084526" style="display:block" class="matches">
                <table cellpadding="0" cellspacing="0">
                    <tr>
                        <td class="Ma_A flag">
                            <a href="javascript:;" class="x">x</a> 
                            <span id="ln-1084526" style="position:relative;">INT CF
                                <span class="lfname">Club Friendly</span>
                            </span>
                            <input type="hidden" value="3" id="sts-1084526" />
                        </td>
                        <td class="time"> 
                                    <span id="ptime-1084526" class="timezone" style="position: relative;">
                                        62
                                    </span>
                                    <span class="kickoff">13:30</span>
                                <span class="date datetimezone">01/30/2014 13:30 GMT</span>
                                <span class="gmtdatetime" style="display:none">01/30/2014 13:30</span>
                        </td>
                        <td class="home">
                             <span id="hg-1084526">
                            </span>
                            <span id="hn-1084526">FC Kobenhavn</span>
                            <span class="card" id="hc-1084526">0</span>
                        </td>
                        <td class="score">
                        
                                <a href="javascript:;" class="scorelink score" matchid="1084526" leaguetitle="Club Friendly" date="1/30/2014 1:30:00 PM">
                                <span id="hs-1084526">0</span> - 
                                <span id="as-1084526">0</span><br />
                                </a>
                        </td>
                        <td class="away">
                            <span id="an-1084526">Bronshoj</span>
                            <span id="ag-1084526">
                            </span>
                            <span class="card" id="ac-1084526">0</span>
                        </td>
                        <td id="live-1084526" class="liveicon"></td>
                        <td class="icons">
                            <a href="/Video/1084526" class="video" title="highlights" style="visibility:hidden"></a>
                            <a id="mm-1084526" class="gccmymatch " href="javascript:;"></a>
                            <a id="setting-1084526" class="sicon" href="javascript:;" title="Pick your own sound"></a>
                        </td>
                    </tr>
                </table>
            </div>
            <div id="1084525" style="display:block" class="matches">
                <table cellpadding="0" cellspacing="0">
                    <tr>
                        <td class="Ma_A flag">
                            <a href="javascript:;" class="x">x</a> 
                            <span id="ln-1084525" style="position:relative;">INT CF
                                <span class="lfname">Club Friendly</span>
                            </span>
                            <input type="hidden" value="3" id="sts-1084525" />
                        </td>
                        <td class="time"> 
                                    <span id="ptime-1084525" class="timezone" style="position: relative;">
                                        87
                                    </span>
                                    <span class="kickoff">13:10</span>
                                <span class="date datetimezone">01/30/2014 13:10 GMT</span>
                                <span class="gmtdatetime" style="display:none">01/30/2014 13:10</span>
                        </td>
                        <td class="home">
                             <span id="hg-1084525">
                            </span>
                            <span id="hn-1084525">Pelister Bitola</span>
                            <span class="card" id="hc-1084525">0</span>
                        </td>
                        <td class="score">
                        
                                <a href="javascript:;" class="scorelink score" matchid="1084525" leaguetitle="Club Friendly" date="1/30/2014 1:10:00 PM">
                                <span id="hs-1084525">0</span> - 
                                <span id="as-1084525">3</span><br />
                                </a>
                        </td>
                        <td class="away">
                            <span id="an-1084525">FK Javor Ivanjica</span>
                            <span id="ag-1084525">
                            </span>
                            <span class="card" id="ac-1084525">0</span>
                        </td>
                        <td id="live-1084525" class="liveicon"></td>
                        <td class="icons">
                            <a href="/Video/1084525" class="video" title="highlights" style="visibility:hidden"></a>
                            <a id="mm-1084525" class="gccmymatch " href="javascript:;"></a>
                            <a id="setting-1084525" class="sicon" href="javascript:;" title="Pick your own sound"></a>
                        </td>
                    </tr>
                </table>
            </div>
            <div class="league-header">
                <table cellpadding="0" cellspacing="0">
                    <tr>
                        <td>
                            <img src='/content/images/flags/46.png' alt=''/>
                            <span>International - Friendly</span>
                        </td>
                    </tr>
                </table>
            </div>
            <div id="1084537" style="display:block" class="matches">
                <table cellpadding="0" cellspacing="0">
                    <tr>
                        <td class="Ma_A flag">
                            <a href="javascript:;" class="x">x</a> 
                            <span id="ln-1084537" style="position:relative;">INTERF
                                <span class="lfname">Friendly</span>
                            </span>
                            <input type="hidden" value="2" id="sts-1084537" />
                        </td>
                        <td class="time"> 
HT                                    <span class="kickoff">14:00</span>
                                <span class="date datetimezone">01/30/2014 14:00 GMT</span>
                                <span class="gmtdatetime" style="display:none">01/30/2014 14:00</span>
                        </td>
                        <td class="home">
                             <span id="hg-1084537">
                            </span>
                            <span id="hn-1084537">Northern Ireland(U17)</span>
                            <span class="card" id="hc-1084537">0</span>
                        </td>
                        <td class="score">
                        
                                <a href="javascript:;" class="scorelink score" matchid="1084537" leaguetitle="Friendly Internationals" date="1/30/2014 2:00:00 PM">
                                <span id="hs-1084537">0</span> - 
                                <span id="as-1084537">0</span><br />
                                </a>
                        </td>
                        <td class="away">
                            <span id="an-1084537">Czech Republic (U17)</span>
                            <span id="ag-1084537">
                            </span>
                            <span class="card" id="ac-1084537">0</span>
                        </td>
                        <td id="live-1084537" class="liveicon"></td>
                        <td class="icons">
                            <a href="/Video/1084537" class="video" title="highlights" style="visibility:hidden"></a>
                            <a id="mm-1084537" class="gccmymatch " href="javascript:;"></a>
                            <a id="setting-1084537" class="sicon" href="javascript:;" title="Pick your own sound"></a>
                        </td>
                    </tr>
                </table>
            </div>
            <div class="league-header">
                <table cellpadding="0" cellspacing="0">
                    <tr>
                        <td>
                            <img src='/content/images/flags/18.png' alt=''/>
                            <span>England - England U21 Professional Development League 2</span>
                        </td>
                    </tr>
                </table>
            </div>
            <div id="1009477" style="display:block" class="matches">
                <table cellpadding="0" cellspacing="0">
                    <tr>
                        <td class="Ma_A flag">
                            <a href="javascript:;" class="x">x</a> 
                            <span id="ln-1009477" style="position:relative;">ENG U21D2
                                <span class="lfname">England U21 Professional Development League 2</span>
                            </span>
                            <input type="hidden" value="3" id="sts-1009477" />
                        </td>
                        <td class="time"> 
                                    <span id="ptime-1009477" class="timezone" style="position: relative;">
                                        62
                                    </span>
                                    <span class="kickoff">13:30</span>
                                <span class="date datetimezone">01/30/2014 13:30 GMT</span>
                                <span class="gmtdatetime" style="display:none">01/30/2014 13:30</span>
                        </td>
                        <td class="home">
                             <span id="hg-1009477">
                            </span>
                            <span id="hn-1009477">Brentford(U21)</span>
                            <span class="card" id="hc-1009477">0</span>
                        </td>
                        <td class="score">
                        
                                <a href="javascript:;" class="scorelink score" matchid="1009477" leaguetitle="England U21 Professional Development League 2" date="1/30/2014 1:30:00 PM">
                                <span id="hs-1009477">0</span> - 
                                <span id="as-1009477">0</span><br />
                                </a>
                        </td>
                        <td class="away">
                            <span id="an-1009477">Swansea City(U21)</span>
                            <span id="ag-1009477">
                            </span>
                            <span class="card" id="ac-1009477">0</span>
                        </td>
                        <td id="live-1009477" class="liveicon"></td>
                        <td class="icons">
                            <a href="/Video/1009477" class="video" title="highlights" style="visibility:hidden"></a>
                            <a id="mm-1009477" class="gccmymatch " href="javascript:;"></a>
                            <a id="setting-1009477" class="sicon" href="javascript:;" title="Pick your own sound"></a>
                        </td>
                    </tr>
                </table>
            </div>
            <div class="league-header">
                <table cellpadding="0" cellspacing="0">
                    <tr>
                        <td>
                            <img src='/content/images/flags/14.png' alt=''/>
                            <span>Italy - Campionato Primavera</span>
                        </td>
                    </tr>
                </table>
            </div>
            <div id="1010531" style="display:block" class="matches">
                <table cellpadding="0" cellspacing="0">
                    <tr>
                        <td class="Ma_A flag">
                            <a href="javascript:;" class="x">x</a> 
                            <span id="ln-1010531" style="position:relative;">ITA YTHL
                                <span class="lfname">Campionato Primavera</span>
                            </span>
                            <input type="hidden" value="1" id="sts-1010531" />
                        </td>
                        <td class="time"> 
                                    <span id="ptime-1010531" class="timezone" style="position: relative;">
                                        45
                                    </span>
                                    <span class="kickoff">14:00</span>
                                <span class="date datetimezone">01/30/2014 14:00 GMT</span>
                                <span class="gmtdatetime" style="display:none">01/30/2014 14:00</span>
                        </td>
                        <td class="home">
                             <span id="hg-1010531">
                            </span>
                            <span id="hn-1010531">Sampdoria Youth</span>
                            <span class="card" id="hc-1010531">0</span>
                        </td>
                        <td class="score">
                        
                                <a href="javascript:;" class="scorelink score" matchid="1010531" leaguetitle="Italian Campionato Primavera" date="1/30/2014 2:00:00 PM">
                                <span id="hs-1010531">2</span> - 
                                <span id="as-1010531">0</span><br />
                                </a>
                        </td>
                        <td class="away">
                            <span id="an-1010531">Siena Youth</span>
                            <span id="ag-1010531">
                                    <span class="redcard"></span>
                            </span>
                            <span class="card" id="ac-1010531">1</span>
                        </td>
                        <td id="live-1010531" class="liveicon"></td>
                        <td class="icons">
                            <a href="/Video/1010531" class="video" title="highlights" style="visibility:hidden"></a>
                            <a id="mm-1010531" class="gccmymatch " href="javascript:;"></a>
                            <a id="setting-1010531" class="sicon" href="javascript:;" title="Pick your own sound"></a>
                        </td>
                    </tr>
                </table>
            </div>
            <div id="1010530" style="display:block" class="matches">
                <table cellpadding="0" cellspacing="0">
                    <tr>
                        <td class="Ma_A flag">
                            <a href="javascript:;" class="x">x</a> 
                            <span id="ln-1010530" style="position:relative;">ITA YTHL
                                <span class="lfname">Campionato Primavera</span>
                            </span>
                            <input type="hidden" value="3" id="sts-1010530" />
                        </td>
                        <td class="time"> 
                                    <span id="ptime-1010530" class="timezone" style="position: relative;">
                                        -29084
                                    </span>
                                    <span class="kickoff">13:30</span>
                                <span class="date datetimezone">01/30/2014 13:30 GMT</span>
                                <span class="gmtdatetime" style="display:none">01/30/2014 13:30</span>
                        </td>
                        <td class="home">
                             <span id="hg-1010530">
                            </span>
                            <span id="hn-1010530">Parma Youth</span>
                            <span class="card" id="hc-1010530">0</span>
                        </td>
                        <td class="score">
                        
                                <a href="javascript:;" class="scorelink score" matchid="1010530" leaguetitle="Italian Campionato Primavera" date="1/30/2014 1:30:00 PM">
                                <span id="hs-1010530">0</span> - 
                                <span id="as-1010530">0</span><br />
                                </a>
                        </td>
                        <td class="away">
                            <span id="an-1010530">Sassuolo Calcio Youth</span>
                            <span id="ag-1010530">
                            </span>
                            <span class="card" id="ac-1010530">0</span>
                        </td>
                        <td id="live-1010530" class="liveicon"></td>
                        <td class="icons">
                            <a href="/Video/1010530" class="video" title="highlights" style="visibility:hidden"></a>
                            <a id="mm-1010530" class="gccmymatch " href="javascript:;"></a>
                            <a id="setting-1010530" class="sicon" href="javascript:;" title="Pick your own sound"></a>
                        </td>
                    </tr>
                </table>
            </div>
            <div id="1010529" style="display:block" class="matches">
                <table cellpadding="0" cellspacing="0">
                    <tr>
                        <td class="Ma_A flag">
                            <a href="javascript:;" class="x">x</a> 
                            <span id="ln-1010529" style="position:relative;">ITA YTHL
                                <span class="lfname">Campionato Primavera</span>
                            </span>
                            <input type="hidden" value="3" id="sts-1010529" />
                        </td>
                        <td class="time"> 
                                    <span id="ptime-1010529" class="timezone" style="position: relative;">
                                        54
                                    </span>
                                    <span class="kickoff">13:30</span>
                                <span class="date datetimezone">01/30/2014 13:30 GMT</span>
                                <span class="gmtdatetime" style="display:none">01/30/2014 13:30</span>
                        </td>
                        <td class="home">
                             <span id="hg-1010529">
                            </span>
                            <span id="hn-1010529">Modena Youth</span>
                            <span class="card" id="hc-1010529">0</span>
                        </td>
                        <td class="score">
                        
                                <a href="javascript:;" class="scorelink score" matchid="1010529" leaguetitle="Italian Campionato Primavera" date="1/30/2014 1:30:00 PM">
                                <span id="hs-1010529">1</span> - 
                                <span id="as-1010529">0</span><br />
                                </a>
                        </td>
                        <td class="away">
                            <span id="an-1010529">Genoa Youth</span>
                            <span id="ag-1010529">
                            </span>
                            <span class="card" id="ac-1010529">0</span>
                        </td>
                        <td id="live-1010529" class="liveicon"></td>
                        <td class="icons">
                            <a href="/Video/1010529" class="video" title="highlights" style="visibility:hidden"></a>
                            <a id="mm-1010529" class="gccmymatch " href="javascript:;"></a>
                            <a id="setting-1010529" class="sicon" href="javascript:;" title="Pick your own sound"></a>
                        </td>
                    </tr>
                </table>
            </div>
            <div id="1010999" style="display:block" class="matches">
                <table cellpadding="0" cellspacing="0">
                    <tr>
                        <td class="Ma_A flag">
                            <a href="javascript:;" class="x">x</a> 
                            <span id="ln-1010999" style="position:relative;">ITA YTHL
                                <span class="lfname">Campionato Primavera</span>
                            </span>
                            <input type="hidden" value="3" id="sts-1010999" />
                        </td>
                        <td class="time"> 
                                    <span id="ptime-1010999" class="timezone" style="position: relative;">
                                        90
                                    </span>
                                    <span class="kickoff">13:00</span>
                                <span class="date datetimezone">01/30/2014 13:00 GMT</span>
                                <span class="gmtdatetime" style="display:none">01/30/2014 13:00</span>
                        </td>
                        <td class="home">
                             <span id="hg-1010999">
                                <span class="redcard"></span>
                                <span class="redcard"></span>
                            </span>
                            <span id="hn-1010999">Crotone Youth</span>
                            <span class="card" id="hc-1010999">2</span>
                        </td>
                        <td class="score">
                        
                                <a href="javascript:;" class="scorelink score" matchid="1010999" leaguetitle="Italian Campionato Primavera" date="1/30/2014 1:00:00 PM">
                                <span id="hs-1010999">0</span> - 
                                <span id="as-1010999">2</span><br />
                                </a>
                        </td>
                        <td class="away">
                            <span id="an-1010999">Napoli Youth</span>
                            <span id="ag-1010999">
                            </span>
                            <span class="card" id="ac-1010999">0</span>
                        </td>
                        <td id="live-1010999" class="liveicon"></td>
                        <td class="icons">
                            <a href="/Video/1010999" class="video" title="highlights" style="visibility:hidden"></a>
                            <a id="mm-1010999" class="gccmymatch " href="javascript:;"></a>
                            <a id="setting-1010999" class="sicon" href="javascript:;" title="Pick your own sound"></a>
                        </td>
                    </tr>
                </table>
            </div>
            <div class="league-header">
                <table cellpadding="0" cellspacing="0">
                    <tr>
                        <td>
                            <img src='/content/images/flags/14.png' alt=''/>
                            <span>Italy - C1 B</span>
                        </td>
                    </tr>
                </table>
            </div>
            <div id="1012498" style="display:block" class="matches">
                <table cellpadding="0" cellspacing="0">
                    <tr>
                        <td class="Ma_A flag">
                            <a href="javascript:;" class="x">x</a> 
                            <span id="ln-1012498" style="position:relative;">ITA C1-B
                                <span class="lfname">C1 B</span>
                            </span>
                            <input type="hidden" value="3" id="sts-1012498" />
                        </td>
                        <td class="time"> 
                                    <span id="ptime-1012498" class="timezone" style="position: relative;">
                                        63
                                    </span>
                                    <span class="kickoff">13:30</span>
                                <span class="date datetimezone">01/30/2014 13:30 GMT</span>
                                <span class="gmtdatetime" style="display:none">01/30/2014 13:30</span>
                        </td>
                        <td class="home">
                             <span id="hg-1012498">
                            </span>
                            <span id="hn-1012498">Esperia Viareggio</span>
                            <span class="card" id="hc-1012498">0</span>
                        </td>
                        <td class="score">
                        
                                <a href="javascript:;" class="scorelink score" matchid="1012498" leaguetitle="Italy C1B" date="1/30/2014 1:30:00 PM">
                                <span id="hs-1012498">0</span> - 
                                <span id="as-1012498">0</span><br />
                                </a>
                        </td>
                        <td class="away">
                            <span id="an-1012498">Pontedera</span>
                            <span id="ag-1012498">
                            </span>
                            <span class="card" id="ac-1012498">0</span>
                        </td>
                        <td id="live-1012498" class="liveicon"></td>
                        <td class="icons">
                            <a href="/Video/1012498" class="video" title="highlights" style="visibility:hidden"></a>
                            <a id="mm-1012498" class="gccmymatch " href="javascript:;"></a>
                            <a id="setting-1012498" class="sicon" href="javascript:;" title="Pick your own sound"></a>
                        </td>
                    </tr>
                </table>
            </div>
            <div class="league-header">
                <table cellpadding="0" cellspacing="0">
                    <tr>
                        <td>
                            <img src='/content/images/flags/5.png' alt=''/>
                            <span>Saudi Arabia - Division 1</span>
                        </td>
                    </tr>
                </table>
            </div>
            <div id="1016056" style="display:block" class="matches">
                <table cellpadding="0" cellspacing="0">
                    <tr>
                        <td class="Ma_A flag">
                            <a href="javascript:;" class="x">x</a> 
                            <span id="ln-1016056" style="position:relative;">KSA D1
                                <span class="lfname">Division 1</span>
                            </span>
                            <input type="hidden" value="3" id="sts-1016056" />
                        </td>
                        <td class="time"> 
                                    <span id="ptime-1016056" class="timezone" style="position: relative;">
                                        87
                                    </span>
                                    <span class="kickoff">13:05</span>
                                <span class="date datetimezone">01/30/2014 13:05 GMT</span>
                                <span class="gmtdatetime" style="display:none">01/30/2014 13:05</span>
                        </td>
                        <td class="home">
                             <span id="hg-1016056">
                            </span>
                            <span id="hn-1016056">Abha</span>
                            <span class="card" id="hc-1016056">0</span>
                        </td>
                        <td class="score">
                        
                                <a href="javascript:;" class="scorelink score" matchid="1016056" leaguetitle="Saudi Arabia Division 1" date="1/30/2014 1:05:00 PM">
                                <span id="hs-1016056">0</span> - 
                                <span id="as-1016056">1</span><br />
                                </a>
                        </td>
                        <td class="away">
                            <span id="an-1016056">Al-Ansar</span>
                            <span id="ag-1016056">
                            </span>
                            <span class="card" id="ac-1016056">0</span>
                        </td>
                        <td id="live-1016056" class="liveicon"></td>
                        <td class="icons">
                            <a href="/Video/1016056" class="video" title="highlights" style="visibility:hidden"></a>
                            <a id="mm-1016056" class="gccmymatch " href="javascript:;"></a>
                            <a id="setting-1016056" class="sicon" href="javascript:;" title="Pick your own sound"></a>
                        </td>
                    </tr>
                </table>
            </div>
  
</div>

Open in new window

0
 

Author Comment

by:runnerjp2005
ID: 39821401
i did // instead of ./ and it worked :S either way case closed lol...

can i just ask if you have any resource ou could recommend for quick commands for HtmlAgilityPack anywhere?>
0
 
LVL 19

Accepted Solution

by:
Ken Butters earned 2000 total points
ID: 39821413
when you do this:

 htmlDoc.DocumentNode.SelectNodes("//div[@class='matches']")

it selects EVERY DIV from your document where the class is equal to matches.

one of the Div's (the first one with class='matches')  from the example you posted is  this:

    <div style="display:block" class="matches" id="matcheshd">
            <a id="lnkCount" href="javascript:;">11 Matches</a>
            <a id="lnkHidden" href="javascript:;">Show Hidden (<span id="hRows">0</span>)</a>
            <a id="btnAudio" href="javascript:;"></a>
            <a id="btnTextSize" href="javascript:;"></a>
    </div>

Open in new window


In this particular DIV the class='matches' so it will be returned your list of nodes... but notice that it does not have a node with class='score' inside of it.

so you when you use the command Div.selectSingleNode("./td[@class='score']") on this particular div... the result will be null.
0
 
LVL 19

Expert Comment

by:Ken Butters
ID: 39821438
I don't have any particular documentation on the HTML agility pack in particular because I've never worked with it before....

But all you questions were more related to Document processing with the Document Object Model... which is pretty much standard no matter what language you are using.

This might get you started:
http://msdn.microsoft.com/en-us/library/ms757828(v=vs.85).aspx
0

Featured Post

Give Your Engineering Team a Productivity Boost

Learn why container technology is so powerful and how it can provide your team with productivity gains and other benefits.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month8 days, 20 hours left to enroll

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question