nottingham Posted August 23, 2011 Share Posted August 23, 2011 <span class="fn"><a href="/wiki/Brad_Jones_(footballer)" title="Brad Jones (footballer)">Brad Jones</a></span></td> </tr> <tr class="vcard agent"> <td style="text-align: right;">2</td> <td style="text-align: right;"><span class="flagicon"><a href="/wiki/England" title="England"><img alt="England" src="http://upload.wikimedia.org/wikipedia/commons/thumb/b/be/Flag_of_England.svg/22px-Flag_of_England.svg.png" width="22" height="13" class="thumbborder" /></a></span></td> <td style="text-align: center;"><a href="/wiki/Defender_(association_football)" title="Defender (association football)">DF</a></td> <td><span class="fn"><a href="/wiki/Glen_Johnson_(English_footballer)" title="Glen Johnson (English footballer)">Glen Johnson</a></span></td> </tr> <tr class="vcard agent"> <td style="text-align: right;">3</td> <td style="text-align: right;"><span class="flagicon"><a href="/wiki/Spain" title="Spain"><img alt="Spain" src="http://upload.wikimedia.org/wikipedia/commons/thumb/9/9a/Flag_of_Spain.svg/22px-Flag_of_Spain.svg.png" width="22" height="15" class="thumbborder" /></a></span></td> <td style="text-align: center;"><a href="/wiki/Defender_(association_football)" title="Defender (association football)">DF</a></td> <td><span class="fn"><a href="/wiki/Jos%C3%A9_Enrique_S%C3%A1nchez" title="José Enrique Sánchez">José Enrique</a></span></td> </tr> <tr class="vcard agent"> <td style="text-align: right;">4</td> <td style="text-align: right;"><span class="flagicon"><a href="/wiki/Portugal" title="Portugal"><img alt="Portugal" src="http://upload.wikimedia.org/wikipedia/commons/thumb/5/5c/Flag_of_Portugal.svg/22px-Flag_of_Portugal.svg.png" width="22" height="15" class="thumbborder" /></a></span></td> <td style="text-align: center;"><a href="/wiki/Midfielder" title="Midfielder">MF</a></td> <td><span class="fn"><a href="/wiki/Raul_Meireles" title="Raul Meireles">Raul Meireles</a></span></td> </tr> <tr class="vcard agent"> <td style="text-align: right;">5</td> <td style="text-align: right;"><span class="flagicon"><a href="/wiki/Denmark" title="Denmark"><img alt="Denmark" src="http://upload.wikimedia.org/wikipedia/commons/thumb/9/9c/Flag_of_Denmark.svg/22px-Flag_of_Denmark.svg.png" width="22" height="17" class="thumbborder" /></a></span></td> <td style="text-align: center;"><a href="/wiki/Defender_(association_football)" title="Defender (association football)">DF</a></td> <td><span class="fn"><a href="/wiki/Daniel_Agger" title="Daniel Agger">Daniel Agger</a></span></td> </tr> <tr class="vcard agent"> <td style="text-align: right;">6</td> <td style="text-align: right;"><span class="flagicon"><a href="/wiki/Brazil" title="Brazil"><img alt="Brazil" src="http://upload.wikimedia.org/wikipedia/commons/thumb/0/05/Flag_of_Brazil.svg/22px-Flag_of_Brazil.svg.png" width="22" height="15" class="thumbborder" /></a></span></td> <td style="text-align: center;"><a href="/wiki/Defender_(association_football)" title="Defender (association football)">DF</a></td> <td><span class="fn"><a href="/wiki/F%C3%A1bio_Aur%C3%A9lio" title="Fábio Aurélio">Fábio Aurélio</a></span></td> </tr> <tr class="vcard agent"> <td style="text-align: right;">7</td> <td style="text-align: right;"><span class="flagicon"><a href="/wiki/Uruguay" title="Uruguay"><img alt="Uruguay" src="http://upload.wikimedia.org/wikipedia/commons/thumb/f/fe/Flag_of_Uruguay.svg/22px-Flag_of_Uruguay.svg.png" width="22" height="15" class="thumbborder" /></a></span></td> <td style="text-align: center;"><a href="/wiki/Forward_(association_football)" title="Forward (association football)">FW</a></td> <td><span class="fn"><a href="/wiki/Luis_Su%C3%A1rez_(Uruguyan_footballer)" title="Luis Suárez (Uruguyan footballer)" class="mw-redirect">Luis Suárez</a></span></td> </tr> <tr class="vcard agent"> <td style="text-align: right;">8</td> <td style="text-align: right;"><span class="flagicon"><a href="/wiki/England" title="England"><img alt="England" src="http://upload.wikimedia.org/wikipedia/commons/thumb/b/be/Flag_of_England.svg/22px-Flag_of_England.svg.png" width="22" height="13" class="thumbborder" /></a></span></td> <td style="text-align: center;"><a href="/wiki/Midfielder" title="Midfielder">MF</a></td> <td><span class="fn"><a href="/wiki/Steven_Gerrard" title="Steven Gerrard">Steven Gerrard</a></span> <i>(<a href="/wiki/Captain_(association_football)" title="Captain (association football)">captain</a>)</i></td> </tr> <tr class="vcard agent"> <td style="text-align: right;">9</td> <td style="text-align: right;"><span class="flagicon"><a href="/wiki/England" title="England"><img alt="England" src="http://upload.wikimedia.org/wikipedia/commons/thumb/b/be/Flag_of_England.svg/22px-Flag_of_England.svg.png" width="22" height="13" class="thumbborder" /></a></span></td> <td style="text-align: center;"><a href="/wiki/Forward_(association_football)" title="Forward (association football)">FW</a></td> <td><span class="fn"><a href="/wiki/Andy_Carroll" title="Andy Carroll">Andy Carroll</a></span></td> </tr> <tr class="vcard agent"> <td style="text-align: right;">10</td> <td style="text-align: right;"><span class="flagicon"><a href="/wiki/England" title="England"><img alt="England" src="http://upload.wikimedia.org/wikipedia/commons/thumb/b/be/Flag_of_England.svg/22px-Flag_of_England.svg.png" width="22" height="13" class="thumbborder" /></a></span></td> <td style="text-align: center;"><a href="/wiki/Midfielder" title="Midfielder">MF</a></td> <td><span class="fn"><a href="/wiki/Joe_Cole" title="Joe Cole">Joe Cole</a></span></td> </tr> <tr class="vcard agent"> <td style="text-align: right;">11</td> <td style="text-align: right;"><span class="flagicon"><a href="/wiki/Argentina" title="Argentina"><img alt="Argentina" src="http://upload.wikimedia.org/wikipedia/commons/thumb/1/1a/Flag_of_Argentina.svg/22px-Flag_of_Argentina.svg.png" width="22" height="14" class="thumbborder" /></a></span></td> <td style="text-align: center;"><a href="/wiki/Midfielder" title="Midfielder">MF</a></td> <td><span class="fn"><a href="/wiki/Maxi_Rodr%C3%ADguez" title="Maxi Rodríguez">Maxi Rodríguez</a></span></td> </tr> <tr class="vcard agent"> <td style="text-align: right;">12</td> <td style="text-align: right;"><span class="flagicon"><a href="/wiki/Spain" title="Spain"><img alt="Spain" src="http://upload.wikimedia.org/wikipedia/commons/thumb/9/9a/Flag_of_Spain.svg/22px-Flag_of_Spain.svg.png" width="22" height="15" class="thumbborder" /></a></span></td> <td style="text-align: center;"><a href="/wiki/Forward_(association_football)" title="Forward (association football)">FW</a></td> <td><span class="fn"><a href="/wiki/Daniel_Pacheco" title="Daniel Pacheco">Daniel Pacheco</a></span></td> </tr> <tr class="vcard agent"> <td style="text-align: right;">14</td> <td style="text-align: right;"><span class="flagicon"><a href="/wiki/England" title="England"><img alt="England" src="http://upload.wikimedia.org/wikipedia/commons/thumb/b/be/Flag_of_England.svg/22px-Flag_of_England.svg.png" width="22" height="13" class="thumbborder" /></a></span></td> <td style="text-align: center;"><a href="/wiki/Midfielder" title="Midfielder">MF</a></td> <td><span class="fn"><a href="/wiki/Jordan_Henderson" title="Jordan Henderson">Jordan Henderson</a></span></td> </tr> <tr class="vcard agent"> <td style="text-align: right;">15</td> <td style="text-align: right;"><span class="flagicon"><a href="/wiki/Italy" title="Italy"><img alt="Italy" src="http://upload.wikimedia.org/wikipedia/commons/thumb/0/03/Flag_of_Italy.svg/22px-Flag_of_Italy.svg.png" width="22" height="15" class="thumbborder" /></a></span></td> <td style="text-align: center;"><a href="/wiki/Midfielder" title="Midfielder">MF</a></td> <td><span class="fn"><a href="/wiki/Alberto_Aquilani" title="Alberto Aquilani">Alberto Aquilani</a></span></td> </tr> <tr class="vcard agent"> <td style="text-align: right;">18</td> <td style="text-align: right;"><span class="flagicon"><a href="/wiki/Netherlands" title="Netherlands"><img alt="Netherlands" src="http://upload.wikimedia.org/wikipedia/commons/thumb/2/20/Flag_of_the_Netherlands.svg/22px-Flag_of_the_Netherlands.svg.png" width="22" height="15" class="thumbborder" /></a></span></td> <td style="text-align: center;"><a href="/wiki/Forward_(association_football)" title="Forward (association football)">FW</a></td> <td><span class="fn"><a href="/wiki/Dirk_Kuyt" title="Dirk Kuyt">Dirk Kuyt</a></span></td> </tr> <tr class="vcard agent"> <td style="text-align: right;">19</td> <td style="text-align: right;"><span class="flagicon"><a href="/wiki/England" title="England"><img alt="England" src="http://upload.wikimedia.org/wikipedia/commons/thumb/b/be/Flag_of_England.svg/22px-Flag_of_England.svg.png" width="22" height="13" class="thumbborder" /></a></span></td> <td style="text-align: center;"><a href="/wiki/Midfielder" title="Midfielder">MF</a></td> <td><span class="fn"><a href="/wiki/Stewart_Downing" title="Stewart Downing">Stewart Downing</a></span></td> </tr> <tr class="vcard agent"> <td style="text-align: right;">20</td> <td style="text-align: right;"><span class="flagicon"><a href="/wiki/England" title="England"><img alt="England" src="http://upload.wikimedia.org/wikipedia/commons/thumb/b/be/Flag_of_England.svg/22px-Flag_of_England.svg.png" width="22" height="13" class="thumbborder" /></a></span></td> <td style="text-align: center;"><a href="/wiki/Midfielder" title="Midfielder">MF</a></td> <td><span class="fn"><a href="/wiki/Jay_Spearing" title="Jay Spearing">Jay Spearing</a></span></td> </tr> <tr class="vcard agent"> <td style="text-align: right;">21</td> <td style="text-align: right;"><span class="flagicon"><a href="/wiki/Brazil" title="Brazil"><img alt="Brazil" src="http://upload.wikimedia.org/wikipedia/commons/thumb/0/05/Flag_of_Brazil.svg/22px-Flag_of_Brazil.svg.png" width="22" height="15" class="thumbborder" /></a></span></td> <td style="text-align: center;"><a href="/wiki/Midfielder" title="Midfielder">MF</a></td> <td><span class="fn"><a href="/wiki/Lucas_Leiva" title="Lucas Leiva">Lucas Leiva</a></span></td> </tr> <tr class="vcard agent"> <td style="text-align: right;">22</td> <td style="text-align: right;"><span class="flagicon"><a href="/wiki/Scotland" title="Scotland"><img alt="Scotland" src="http://upload.wikimedia.org/wikipedia/commons/thumb/1/10/Flag_of_Scotland.svg/22px-Flag_of_Scotland.svg.png" width="22" height="13" class="thumbborder" /></a></span></td> <td style="text-align: center;"><a href="/wiki/Defender_(association_football)" title="Defender (association football)">DF</a></td> <td><span class="fn"><a href="/wiki/Danny_Wilson_(Scottish_footballer)" title="Danny Wilson (Scottish footballer)">Danny Wilson</a></span></td> </tr> </table> </td> <td width="1%"></td> <td bgcolor="#FFFFFF" valign="top" width="48%"> <table border="0" cellspacing="0" cellpadding="2"> <tr bgcolor="#AAD0FF"> <th width="1%">No.</th> <th width="1%"></th> <th width="1%">Position</th> <th width="75%">Player</th> </tr> <tr class="vcard agent"> <td style="text-align: right;">23</td> <td style="text-align: right;"><span class="flagicon"><a href="/wiki/England" title="England"><img alt="England" src="http://upload.wikimedia.org/wikipedia/commons/thumb/b/be/Flag_of_England.svg/22px-Flag_of_England.svg.png" width="22" height="13" class="thumbborder" /></a></span></td> <td style="text-align: center;"><a href="/wiki/Defender_(association_football)" title="Defender (association football)">DF</a></td> <td><span class="fn"><a href="/wiki/Jamie_Carragher" title="Jamie Carragher">Jamie Carragher</a></span> <i>(<a href="/wiki/Captain_(association_football)#Vice-captain" title="Captain (association football)">vice-captain</a>)</i></td> </tr> <tr class="vcard agent"> <td style="text-align: right;">24</td> <td style="text-align: right;"><span class="flagicon"><a href="/wiki/France" title="France"><img alt="France" src="http://upload.wikimedia.org/wikipedia/commons/thumb/c/c3/Flag_of_France.svg/22px-Flag_of_France.svg.png" width="22" height="15" class="thumbborder" /></a></span></td> <td style="text-align: center;"><a href="/wiki/Forward_(association_football)" title="Forward (association football)">FW</a></td> <td><span class="fn"><a href="/wiki/David_N%27Gog" title="David N'Gog">David N'Gog</a></span></td> </tr> <tr class="vcard agent"> <td style="text-align: right;">25</td> <td style="text-align: right;"><span class="flagicon"><a href="/wiki/Spain" title="Spain"><img alt="Spain" src="http://upload.wikimedia.org/wikipedia/commons/thumb/9/9a/Flag_of_Spain.svg/22px-Flag_of_Spain.svg.png" width="22" height="15" class="thumbborder" /></a></span></td> <td style="text-align: center;"><a href="/wiki/Goalkeeper_(association_football)" title="Goalkeeper (association football)">GK</a></td> <td><span class="fn"><a href="/wiki/Jos%C3%A9_Manuel_Reina" title="José Manuel Reina">Pepe Reina</a></span></td> </tr> <tr class="vcard agent"> <td style="text-align: right;">26</td> <td style="text-align: right;"><span class="flagicon"><a href="/wiki/Scotland" title="Scotland"><img alt="Scotland" src="http://upload.wikimedia.org/wikipedia/commons/thumb/1/10/Flag_of_Scotland.svg/22px-Flag_of_Scotland.svg.png" width="22" height="13" class="thumbborder" /></a></span></td> <td style="text-align: center;"><a href="/wiki/Midfielder" title="Midfielder">MF</a></td> <td><span class="fn"><a href="/wiki/Charlie_Adam" title="Charlie Adam">Charlie Adam</a></span></td> </tr> <tr class="vcard agent"> <td style="text-align: right;">28</td> <td style="text-align: right;"><span class="flagicon"><a href="/wiki/Denmark" title="Denmark"><img alt="Denmark" src="http://upload.wikimedia.org/wikipedia/commons/thumb/9/9c/Flag_of_Denmark.svg/22px-Flag_of_Denmark.svg.png" width="22" height="17" class="thumbborder" /></a></span></td> <td style="text-align: center;"><a href="/wiki/Midfielder" title="Midfielder">MF</a></td> <td><span class="fn"><a href="/wiki/Christian_Poulsen" title="Christian Poulsen">Christian Poulsen</a></span></td> </tr> <tr class="vcard agent"> <td style="text-align: right;">30</td> <td style="text-align: right;"><span class="flagicon"><a href="/wiki/Spain" title="Spain"><img alt="Spain" src="http://upload.wikimedia.org/wikipedia/commons/thumb/9/9a/Flag_of_Spain.svg/22px-Flag_of_Spain.svg.png" width="22" height="15" class="thumbborder" /></a></span></td> <td style="text-align: center;"><a href="/wiki/Forward_(association_football)" title="Forward (association football)">FW</a></td> <td><span class="fn">Jesús Fernández Sáez (Suso)</span></td> </tr> <tr class="vcard agent"> <td style="text-align: right;">31</td> <td style="text-align: right;"><span class="flagicon"><a href="/wiki/England" title="England"><img alt="England" src="http://upload.wikimedia.org/wikipedia/commons/thumb/b/be/Flag_of_England.svg/22px-Flag_of_England.svg.png" width="22" height="13" class="thumbborder" /></a></span></td> <td style="text-align: center;"><a href="/wiki/Midfielder" title="Midfielder">MF</a></td> <td><span class="fn"><a href="/wiki/Raheem_Sterling" title="Raheem Sterling">Raheem Sterling</a></span></td> </tr> <tr class="vcard agent"> <td style="text-align: right;">32</td> <td style="text-align: right;"><span class="flagicon"><a href="/wiki/Brazil" title="Brazil"><img alt="Brazil" src="http://upload.wikimedia.org/wikipedia/commons/thumb/0/05/Flag_of_Brazil.svg/22px-Flag_of_Brazil.svg.png" width="22" height="15" class="thumbborder" /></a></span></td> <td style="text-align: center;"><a href="/wiki/Goalkeeper_(association_football)" title="Goalkeeper (association football)">GK</a></td> <td><span class="fn"><a href="/wiki/Doni%C3%A9ber_Alexander_Marangon" title="Doniéber Alexander Marangon">Doni</a></span></td> </tr> <tr class="vcard agent"> <td style="text-align: right;">33</td> <td style="text-align: right;"><span class="flagicon"><a href="/wiki/England" title="England"><img alt="England" src="http://upload.wikimedia.org/wikipedia/commons/thumb/b/be/Flag_of_England.svg/22px-Flag_of_England.svg.png" width="22" height="13" class="thumbborder" /></a></span></td> <td style="text-align: center;"><a href="/wiki/Midfielder" title="Midfielder">MF</a></td> <td><span class="fn"><a href="/wiki/Jonjo_Shelvey" title="Jonjo Shelvey">Jonjo Shelvey</a></span></td> </tr> <tr class="vcard agent"> <td style="text-align: right;">34</td> <td style="text-align: right;"><span class="flagicon"><a href="/wiki/England" title="England"><img alt="England" src="http://upload.wikimedia.org/wikipedia/commons/thumb/b/be/Flag_of_England.svg/22px-Flag_of_England.svg.png" width="22" height="13" class="thumbborder" /></a></span></td> <td style="text-align: center;"><a href="/wiki/Defender_(association_football)" title="Defender (association football)">DF</a></td> <td><span class="fn"><a href="/wiki/Martin_Kelly" title="Martin Kelly">Martin Kelly</a></span></td> </tr> <tr class="vcard agent"> <td style="text-align: right;">35</td> <td style="text-align: right;"><span class="flagicon"><a href="/wiki/England" title="England"><img alt="England" src="http://upload.wikimedia.org/wikipedia/commons/thumb/b/be/Flag_of_England.svg/22px-Flag_of_England.svg.png" width="22" height="13" class="thumbborder" /></a></span></td> <td style="text-align: center;"><a href="/wiki/Midfielder" title="Midfielder">MF</a></td> <td><span class="fn"><a href="/wiki/Conor_Coady" title="Conor Coady">Conor Coady</a></span></td> </tr> <tr class="vcard agent"> <td style="text-align: right;">37</td> <td style="text-align: right;"><span class="flagicon"><a href="/wiki/Slovakia" title="Slovakia"><img alt="Slovakia" src="http://upload.wikimedia.org/wikipedia/commons/thumb/e/e6/Flag_of_Slovakia.svg/22px-Flag_of_Slovakia.svg.png" width="22" height="15" class="thumbborder" /></a></span></td> <td style="text-align: center;"><a href="/wiki/Defender_(association_football)" title="Defender (association football)">DF</a></td> <td><span class="fn"><a href="/wiki/Martin_%C5%A0krtel" title="Martin Škrtel">Martin Škrtel</a></span></td> </tr> <tr class="vcard agent"> <td style="text-align: right;">38</td> <td style="text-align: right;"><span class="flagicon"><a href="/wiki/England" title="England"><img alt="England" src="http://upload.wikimedia.org/wikipedia/commons/thumb/b/be/Flag_of_England.svg/22px-Flag_of_England.svg.png" width="22" height="13" class="thumbborder" /></a></span></td> <td style="text-align: center;"><a href="/wiki/Defender_(association_football)" title="Defender (association football)">DF</a></td> <td><span class="fn"><a href="/wiki/John_Flanagan_(English_footballer)" title="John Flanagan (English footballer)">John Flanagan</a></span></td> </tr> <tr class="vcard agent"> <td style="text-align: right;">39</td> <td style="text-align: right;"><span class="flagicon"><a href="/wiki/England" title="England"><img alt="England" src="http://upload.wikimedia.org/wikipedia/commons/thumb/b/be/Flag_of_England.svg/22px-Flag_of_England.svg.png" width="22" height="13" class="thumbborder" /></a></span></td> <td style="text-align: center;"><a href="/wiki/Forward_(association_football)" title="Forward (association football)">FW</a></td> <td><span class="fn"><a href="/wiki/Nathan_Eccleston" title="Nathan Eccleston">Nathan Eccleston</a></span></td> </tr> <tr class="vcard agent"> <td style="text-align: right;">47</td> <td style="text-align: right;"><span class="flagicon"><a href="/wiki/England" title="England"><img alt="England" src="http://upload.wikimedia.org/wikipedia/commons/thumb/b/be/Flag_of_England.svg/22px-Flag_of_England.svg.png" width="22" height="13" class="thumbborder" /></a></span></td> <td style="text-align: center;"><a href="/wiki/Defender_(association_football)" title="Defender (association football)">DF</a></td> <td><span class="fn">Andre Wisdom</span></td> </tr> <tr class="vcard agent"> <td style="text-align: right;">49</td> <td style="text-align: right;"><span class="flagicon"><a href="/wiki/England" title="England"><img alt="England" src="http://upload.wikimedia.org/wikipedia/commons/thumb/b/be/Flag_of_England.svg/22px-Flag_of_England.svg.png" width="22" height="13" class="thumbborder" /></a></span></td> <td style="text-align: center;"><a href="/wiki/Defender_(association_football)" title="Defender (association football)">DF</a></td> <td><span class="fn"><a href="/wiki/Jack_Robinson_(footballer_born_1993)" title="Jack Robinson (footballer born 1993)">Jack Robinson</a></span></td> </tr> <tr class="vcard agent"> <td style="text-align: right;">—</td> <td style="text-align: right;"><span class="flagicon"><a href="/wiki/England" title="England"><img alt="England" src="http://upload.wikimedia.org/wikipedia/commons/thumb/b/be/Flag_of_England.svg/22px-Flag_of_England.svg.png" width="22" height="13" class="thumbborder" /></a></span></td> <td style="text-align: center;"><a href="/wiki/Forward_(association_football)" title="Forward (association football)">FW</a></td> <td><span class="fn"><a href="/wiki/David_Amoo" title="David Amoo">David Amoo</a></span></td> </tr> <tr class="vcard agent"> <td style="text-align: right;">—</td> <td style="text-align: right;"><span class="flagicon"><a href="/wiki/Switzerland" title="Switzerland"><img alt="Switzerland" src="http://upload.wikimedia.org/wikipedia/commons/thumb/f/f3/Flag_of_Switzerland.svg/20px-Flag_of_Switzerland.svg.png" width="20" height="20" class="thumbborder" /></a></span></td> <td style="text-align: center;"><a href="/wiki/Defender_(association_football)" title="Defender (association football)">DF</a></td> <td><span class="fn"><a href="/wiki/Philipp_Degen" title="Philipp Degen">Philipp Degen</a></span></td> </tr> <tr class="vcard agent"> <td style="text-align: right;">—</td> <td style="text-align: right;"><span class="flagicon"><a href="/wiki/Argentina" title="Argentina"><img alt="Argentina" src="http://upload.wikimedia.org/wikipedia/commons/thumb/1/1a/Flag_of_Argentina.svg/22px-Flag_of_Argentina.svg.png" width="22" height="14" class="thumbborder" /></a></span></td> <td style="text-align: center;"><a href="/wiki/Defender_(association_football)" title="Defender (association football)">DF</a></td> <td><span class="fn"><a href="/wiki/Emiliano_Ins%C3%BAa" title="Emiliano Insúa">Emiliano Insúa</a></span></td> </tr> </table> How can I get the text (only the text) that's being linked inside every <span class="fn"> </span> tag and put them in a array. Quote Link to comment https://forums.phpfreaks.com/topic/245526-easy-regex-stuff/ Share on other sites More sharing options...
requinix Posted August 23, 2011 Share Posted August 23, 2011 By using something like DOMDocument. $dom = new DOMDocument(); // $dom->load whatever $domxpath = new DOMXPath($dom); foreach ($domxpath->query("//span[@class='fn']/a") as $a) { echo $a->textContent; } Quote Link to comment https://forums.phpfreaks.com/topic/245526-easy-regex-stuff/#findComment-1261103 Share on other sites More sharing options...
nottingham Posted August 24, 2011 Author Share Posted August 24, 2011 By using something like DOMDocument. $dom = new DOMDocument(); // $dom->load whatever $domxpath = new DOMXPath($dom); foreach ($domxpath->query("//span[@class='fn']/a") as $a) { echo $a->textContent; } Thank you very much sir. Also, how could I stop it getting the texts after it reaches </table> Quote Link to comment https://forums.phpfreaks.com/topic/245526-easy-regex-stuff/#findComment-1261266 Share on other sites More sharing options...
requinix Posted August 24, 2011 Share Posted August 24, 2011 By altering the XPath query (the //span thing) so that it only looks in the one table. What Wikipedia page are you looking at? Quote Link to comment https://forums.phpfreaks.com/topic/245526-easy-regex-stuff/#findComment-1261451 Share on other sites More sharing options...
nottingham Posted August 25, 2011 Author Share Posted August 25, 2011 By altering the XPath query (the //span thing) so that it only looks in the one table. What Wikipedia page are you looking at? Thank you for your answer. I'm looking at http://en.wikipedia.org/wiki/Liverpool_F.C. , I now noticed that there are more than one </table> 's at that page. So maybe I should cut that snippet first using maybe substr? Quote Link to comment https://forums.phpfreaks.com/topic/245526-easy-regex-stuff/#findComment-1261832 Share on other sites More sharing options...
silkfire Posted August 25, 2011 Share Posted August 25, 2011 The XPath for this is quite complex and relies on that there exists a heading in the Wikipedia article called "Players": //span[@id="Players"]/../following-sibling::table[1]//span[@class="fn"] Quote Link to comment https://forums.phpfreaks.com/topic/245526-easy-regex-stuff/#findComment-1261854 Share on other sites More sharing options...
nottingham Posted August 25, 2011 Author Share Posted August 25, 2011 The XPath for this is quite complex and relies on that there exists a heading in the Wikipedia article called "Players": //span[@id="Players"]/../following-sibling::table[1]//span[@class="fn"] <?php $file = file_get_contents('http://en.wikipedia.org/wiki/Liverpool_F.C.', true); $dom = new DOMDocument(); $dom->load($file); $domxpath = new DOMXPath($dom); foreach ($domxpath->query("//span[@id="Players"]/../following-sibling::table[1]//span[@class="fn"]") as $a) { echo $a->textContent; } ?> Thank for your answer. I think I should start learning XPath syntax. By the way, do you see any particular problem with this code. Quote Link to comment https://forums.phpfreaks.com/topic/245526-easy-regex-stuff/#findComment-1261884 Share on other sites More sharing options...
silkfire Posted August 25, 2011 Share Posted August 25, 2011 Yeah - use single quotes around the expression foreach ($domxpath->query("//span[@id=Players]/../following-sibling::table[1]//span[@class=fn]") as $a) { ==> foreach ($domxpath->query('//span[@id=Players]/../following-sibling::table[1]//span[@class=fn]') as $a) { Quote Link to comment https://forums.phpfreaks.com/topic/245526-easy-regex-stuff/#findComment-1261906 Share on other sites More sharing options...
nottingham Posted August 25, 2011 Author Share Posted August 25, 2011 Yeah - use single quotes around the expression foreach ($domxpath->query("//span[@id=Players]/../following-sibling::table[1]//span[@class=fn]") as $a) { ==> foreach ($domxpath->query('//span[@id=Players]/../following-sibling::table[1]//span[@class=fn]') as $a) { <?php $file = file_get_contents('http://en.wikipedia.org/wiki/Liverpool_F.C.', true); $dom = new DOMDocument(); $dom->load($file); $domxpath = new DOMXPath($dom); foreach ($domxpath->query('//span[@id="Players"]/../following-sibling::table[1]//span[@class="fn"]') as $a) {echo $a->textContent}; ?> Interesting, still not working. Is there a module that I must enable? Quote Link to comment https://forums.phpfreaks.com/topic/245526-easy-regex-stuff/#findComment-1261959 Share on other sites More sharing options...
silkfire Posted August 25, 2011 Share Posted August 25, 2011 Any error messages? Quote Link to comment https://forums.phpfreaks.com/topic/245526-easy-regex-stuff/#findComment-1261982 Share on other sites More sharing options...
requinix Posted August 25, 2011 Share Posted August 25, 2011 DOMDocument::load() expects a filename, not XML source. Use ::loadHTMLFile(). $dom = new DOMDocument(); $dom->loadHTMLFile('http://en.wikipedia.org/wiki/Liverpool_F.C.'); $domxpath = new DOMXPath($dom); foreach ($domxpath->query('//span[@id="Players"]/../following-sibling::table[1]//span[@class="fn"]') as $a) {echo $a->textContent;}; Also, a shorter query would be //tr[@class=vcard agent]//span[@class=fn]/ but that includes the "Out on loan" players. Quote Link to comment https://forums.phpfreaks.com/topic/245526-easy-regex-stuff/#findComment-1261986 Share on other sites More sharing options...
nottingham Posted August 25, 2011 Author Share Posted August 25, 2011 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html lang="en" dir="ltr" xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta name="description" content="Players of Liverpool F.C." /> <meta name="keywords" content="liverpool, players of liverpool" /> <title>Players of Liverpool F.C.</title> </head> <body> <?php $dom = new DOMDocument(); $dom->loadHTMLFile('http://en.wikipedia.org/wiki/Liverpool_F.C.'); $domxpath = new DOMXPath($dom); foreach ($domxpath->query('//span[@id="Players"]/../following-sibling::table[1]//span[@class="fn"]') as $a) {echo " <p>$a->textContent</p> "; }; ?> </body> </html> Works perfectly, thanks for your help requinix and silkfire. Quote Link to comment https://forums.phpfreaks.com/topic/245526-easy-regex-stuff/#findComment-1262008 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.