PHP Scraper - if table contains td with class = grab all table

Ok so i have done the following
$dom = new DOMDocument();
    $html = $content;
    // load html
    @$dom->loadHTML($html);
    $xpath = new DOMXPath($dom);

    //this will gives you all td with class name is jobs.
    $my_xpath_query = '//table/tr/td[contains(@class, "databreakdown")]';
    $result_rows = $xpath->query($my_xpath_query);

    //iterate all td
    foreach ($result_rows as $result_object){
		        echo $result_object->nodeValue. "<br />";
    }

Open in new window

what i would like to do is if the table contains td[contains(@class, "databreakdown")] then grab the whole table!

at the moment it just returns the td
runnerjp2005Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

gr8gonzoConsultantCommented:
I normally use SimpleHTMLDom for HTML parsing. It might be a better fit for what you're trying to do. You can easily find the TD with that given class and then iterate up to its parent and dump it. Check out my article on how to use it:

http://www.experts-exchange.com/Programming/Languages/Scripting/PHP/A_10277-HTML-Manipulation-Made-Easy.html
0
Ray PaseurCommented:
Depending on the structure of the data, we might be able to do this in "native" PHP.  Can you give us some test data, please?
0
runnerjp2005Author Commented:
<table width=100%><tr class=databreakdown2253><th>Card No</th><th><a href='races.php?fast=23595&sortby=1'>Place</a></th><th>Dist Bt</th><th>Stall</th>
<th>Horse</th><th>Age</th><th><a href='races.php?fast=23595&sortby=3'>Weight</a></th><th>Headgear</th><th>OR</th><th>Trainer</th>
<th><a href='races.php?fast=23595&sortby=2'>Odds</a></th><th>Jockey (Claim)</th></tr><tr><td class=databreakdown2253>1</td><td class=databreakdown2253>1st</td><td class=databreakdown2253></td><td class=databreakdown2253>3</td>
<td class=databreakdown2253><a href='horses.php?id=292624'>Double Discount (IRE)</a></td>
<td class=databreakdown2253>4</td><td class=databreakdown2253>9-10</td><td class=databreakdown2253><a title='Cheekpieces worn'>CkPc</a></td>
<td class=databreakdown2253>85</td>
<td class=databreakdown2253><a href='trainers.php?id=2982'>Dascombe, Tom</a></td>
<td class=databreakdown2253>7/1  </td>
<td class=databreakdown2253><a href='jockeys.php?id=3557'>Kingscote, Richard</a> </td></tr><tr class=databreakdown18><td colspan=12>tracked leader, led over 1f out, kept on well</td></tr><tr><td class=databreakdown2253>2</td><td class=databreakdown2253>2nd</td><td class=databreakdown2253>2</td><td class=databreakdown2253>4</td>
<td class=databreakdown2253><a href='horses.php?id=295660'>Jazz Master</a></td>
<td class=databreakdown2253>4</td><td class=databreakdown2253>9-9</td><td class=databreakdown2253><a title='Blinkers worn'>Blnk</a></td>
<td class=databreakdown2253>84</td>
<td class=databreakdown2253><a href='trainers.php?id=1255'>Cumani, L M</a></td>
<td class=databreakdown2253>7/2  </td>
<td class=databreakdown2253><a href='jockeys.php?id=6075'>Atzeni, Andrea</a> </td></tr><tr class=databreakdown18><td colspan=12>held up in touch, ridden over 1f out, one pace</td></tr><tr><td class=databreakdown2253>4</td><td class=databreakdown2253>3rd</td><td class=databreakdown2253>2.5</td><td class=databreakdown2253>8</td>
<td class=databreakdown2253><a href='horses.php?id=299836'>Masterpaver</a></td>
<td class=databreakdown2253>3</td><td class=databreakdown2253>9-4</td><td class=databreakdown2253></td>
<td class=databreakdown2253>85</td>
<td class=databreakdown2253><a href='trainers.php?id=5'>Bailey, A</a></td>
<td class=databreakdown2253>11/2  </td>
<td class=databreakdown2253><a href='jockeys.php?id=5855'>Harley, M</a> </td></tr><tr class=databreakdown18><td colspan=12>reared and dwelt start, held up behind, good headway over 5f out, soon led, ridden 2f out, headed over 1f out, no extra</td></tr><tr><td class=databreakdown2253>7</td><td class=databreakdown2253>4th</td><td class=databreakdown2253>1.25</td><td class=databreakdown2253>6</td>
<td class=databreakdown2253><a href='horses.php?id=299719'>Sweetheart Abbey</a></td>
<td class=databreakdown2253>3</td><td class=databreakdown2253>9-1</td><td class=databreakdown2253><a title='Cheekpieces worn'>CkPc</a></td>
<td class=databreakdown2253>82</td>
<td class=databreakdown2253><a href='trainers.php?id=3255'>Knight, W J</a></td>
<td class=databreakdown2253>25/1  </td>
<td class=databreakdown2253><a href='jockeys.php?id=685'>Doyle, James</a> </td></tr><tr class=databreakdown18><td colspan=12>held up towards rear, ridden over 1f out, kept on same pace inside final furlong</td></tr><tr><td class=databreakdown2253>6</td><td class=databreakdown2253>5th</td><td class=databreakdown2253>0.5</td><td class=databreakdown2253>10</td>
<td class=databreakdown2253><a href='horses.php?id=299079'>Almerzem (USA)</a></td>
<td class=databreakdown2253>3</td><td class=databreakdown2253>9-2</td><td class=databreakdown2253></td>
<td class=databreakdown2253>83</td>
<td class=databreakdown2253><a href='trainers.php?id=2913'>Suroor, Saeed Bin</a></td>
<td class=databreakdown2253>7/2  </td>
<td class=databreakdown2253><a href='jockeys.php?id=3440'>Hanagan, Paul</a> </td></tr><tr class=databreakdown18><td colspan=12>tracked leaders and keen, ridden over 1f out, no extra</td></tr><tr><td class=databreakdown2253>8</td><td class=databreakdown2253>6th</td><td class=databreakdown2253>NK</td><td class=databreakdown2253>9</td>
<td class=databreakdown2253><a href='horses.php?id=304926'>Clear Mind</a></td>
<td class=databreakdown2253>3</td><td class=databreakdown2253>9-1</td><td class=databreakdown2253></td>
<td class=databreakdown2253>82</td>
<td class=databreakdown2253><a href='trainers.php?id=918'>Gosden, J H M</a></td>
<td class=databreakdown2253>3/1 (Fav) </td>
<td class=databreakdown2253><a href='jockeys.php?id=4094'>Buick, William</a> </td></tr><tr class=databreakdown18><td colspan=12>tracked leaders in 4th, went 2nd over 8f out, ridden over 1f out, kept on same pace</td></tr><tr><td class=databreakdown2253>9</td><td class=databreakdown2253>7th/td><td class=databreakdown2253>2.5</td><td class=databreakdown2253>5</td>
<td class=databreakdown2253><a href='horses.php?id=299642'>Sweeping Up</a></td>
<td class=databreakdown2253>3</td><td class=databreakdown2253>9-0</td><td class=databreakdown2253> <a title='Tongue Tie worn'>TT</a></td>
<td class=databreakdown2253>81</td>
<td class=databreakdown2253><a href='trainers.php?id=781'>Morrison, H</a></td>
<td class=databreakdown2253>8/1  </td>
<td class=databreakdown2253><a href='jockeys.php?id=3422'>Dobbs, Pat</a> </td></tr><tr class=databreakdown18><td colspan=12>led, headed over 4f out, pushed along over 2f out, weakened inside final furlong</td></tr><tr><td class=databreakdown2253>3</td><td class=databreakdown2253>8th</td><td class=databreakdown2253>5</td><td class=databreakdown2253>2</td>
<td class=databreakdown2253><a href='horses.php?id=246131'>Starluck (IRE)</a></td>
<td class=databreakdown2253>9</td><td class=databreakdown2253>9-8</td><td class=databreakdown2253></td>
<td class=databreakdown2253>83</td>
<td class=databreakdown2253><a href='trainers.php?id=450'>Arbuthnot, D W P</a></td>
<td class=databreakdown2253>66/1  </td>
<td class=databreakdown2253><a href='jockeys.php?id=937'>Keniry, L P</a> </td></tr><tr class=databreakdown18><td colspan=12>held up in rear, effort over 2f out, never dangerous</td></tr><tr><td class=databreakdown2253>10</td><td class=databreakdown2253>9th</td><td class=databreakdown2253>10</td><td class=databreakdown2253>7</td>
<td class=databreakdown2253><a href='horses.php?id=251773'>Choral Festival</a></td>
<td class=databreakdown2253>8</td><td class=databreakdown2253>8-10</td><td class=databreakdown2253></td>
<td class=databreakdown2253>69</td>
<td class=databreakdown2253><a href='trainers.php?id=933'>Bridger, J J</a></td>
<td class=databreakdown2253>66/1  </td>
<td class=databreakdown2253><a href='jockeys.php?id=3848'>Carson, William</a> </td></tr><tr class=databreakdown18><td colspan=12>held up towards rear, pushed along over 3f out, soon weakened</td></tr></table><br><hr></td></tr></table>

Open in new window

Ed. note: Code moved into Code Snippet feature.
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

runnerjp2005Author Commented:
@gr8gonz - how do i iterate up to its parent and dump it...unable to find that in the article
0
Julian HansenCommented:
Assumes html is in external file
<?php
  $html = file_get_contents('e006.html');
  $dom = new DOMDocument();
  // load html
  @$dom->loadHTML($html);
  $xpath = new DOMXPath($dom);

  //this will gives you all td with class name is jobs.
  $my_xpath_query = '//table/tr/td[contains(@class, "databreakdown")]';
  $result_rows = $xpath->query($my_xpath_query);
  // First check if we found anything
  if ($result_rows->length > 0) {
    // IF WE DID GET THE PARENT'S <tr> PARENT'S <table> NODE
    $obj = $result_rows->item(0)->parentNode->parentNode;
    // CALL saveHTML ON THE TABLE OBJ TO SAVE TO STRING
    $table = $dom->saveHTML($obj);
    echo $table;
  }
  else {
    echo "Table not found";
  }
?>

Open in new window

0
Ray PaseurCommented:
@runnerjp2005: This is interesting, but not very good test data because it only contains one table and the table is a positive for the search string.  Is there a URL that you're getting this sample from?  If so, please post the URL address so we can test on a data set that is more like what you'll encounter in real life, thanks.
0
runnerjp2005Author Commented:
Hi ray - it requires you to login to get the information -

here is the page:

<html><head><title>Newly Refurbished Genting Casino Brighton Handicap - Race Result - 7th Oct 2014</title>
<meta name="google-site-verification" content="p9VK7t1lSqJAOs1KEsivev9xf0-72tTB-UY8fQm9sXw" />
<meta name='description' content='Brighton - 7th Oct 2014 - Newly Refurbished Genting Casino Brighton Handicap '>
<script type="text/javascript">
var timeout = 500;
var closetimer = 0;
var ddmenuitem = 0;
function make_blank() { document.searchthis.searchhunt.value = ""; }
function make_blank2() { document.ss.systemname.value = ""; }
function nav() { var w = document.myform.mylist.selectedIndex; var url_add = document.myform.mylist.options[w].value; window.location.href = url_add; }
function nav2() { var w = document.myform2.mylist2.selectedIndex; var url_add = document.myform2.mylist2.options[w].value; window.location.href = url_add; }
function nav3() { var w = document.myform3.mylist3.selectedIndex; var url_add = document.myform3.mylist3.options[w].value; window.location.href = url_add; }
function nav4() { var w = document.myform4.mylist4.selectedIndex; var url_add = document.myform4.mylist4.options[w].value; window.location.href = url_add; }
function nav5() { var w = document.myform5.mylist5.selectedIndex; var url_add = document.myform5.mylist5.options[w].value; window.location.href = url_add; }
function nav6() { var w = document.myform6.mylist6.selectedIndex; var url_add = document.myform6.mylist6.options[w].value; window.location.href = url_add; }
function nav555() { var w = document.myform555.mylist555.selectedIndex; var url_add = document.myform555.mylist555.options[w].value; window.location.href = url_add; }
function nav556() { var w = document.myform556.mylist556.selectedIndex; var url_add = document.myform556.mylist556.options[w].value; window.location.href = url_add; }
function go(loc) { window.location.href = loc; }
function mopen(id) { mcancelclosetime(); if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';	ddmenuitem = document.getElementById(id); ddmenuitem.style.visibility = 'visible'; }
function mclose() { if(ddmenuitem) ddmenuitem.style.visibility = 'hidden'; }
function mclosetime() {	closetimer = window.setTimeout(mclose, timeout); }
function mcancelclosetime() { if(closetimer) { window.clearTimeout(closetimer); closetimer = null; }}
document.onclick = mclose; 
function select(a) { var theForm = document.qsform; for (i=0; i<theForm.elements.length; i++) {  if (theForm.elements[i].name=='formtrackid[]') { theForm.elements[i].checked = a; }}}
function selectb(a) { var theForm = document.qsform; for (i=0; i<theForm.elements.length; i++) {  if (theForm.elements[i].name=='formprevtrackid[]') { theForm.elements[i].checked = a; }}}
function selectc(a) { var theForm = document.qsform; for (i=0; i<theForm.elements.length; i++) {  if (theForm.elements[i].name=='formslrtrackid[]') { theForm.elements[i].checked = a; }}}
function selectd(a) { var theForm = document.qsform; for (i=0; i<theForm.elements.length; i++) {  if (theForm.elements[i].name=='formtlrtrackid[]') { theForm.elements[i].checked = a; }}}
function selecte(a) { var theForm = document.qsform; for (i=0; i<theForm.elements.length; i++) {  if (theForm.elements[i].name=='formflrtrackid[]') { theForm.elements[i].checked = a; }}}
function selectf(a) { var theForm = document.qsform; for (i=0; i<theForm.elements.length; i++) {  if (theForm.elements[i].name=='formwintrackid[]') { theForm.elements[i].checked = a; }}}
function selectg(a) { var theForm = document.qsform; for (i=0; i<theForm.elements.length; i++) {  if (theForm.elements[i].name=='jockeyid[]') { theForm.elements[i].checked = a; }}}
function selecth(a) { var theForm = document.qsform; for (i=0; i<theForm.elements.length; i++) {  if (theForm.elements[i].name=='prevjockeyid[]') { theForm.elements[i].checked = a; }}}
function selecti(a) { var theForm = document.qsform; for (i=0; i<theForm.elements.length; i++) {  if (theForm.elements[i].name=='slrjockeyid[]') { theForm.elements[i].checked = a; }}}
function selectj(a) { var theForm = document.qsform; for (i=0; i<theForm.elements.length; i++) {  if (theForm.elements[i].name=='tlrjockeyid[]') { theForm.elements[i].checked = a; }}}
function selectk(a) { var theForm = document.qsform; for (i=0; i<theForm.elements.length; i++) {  if (theForm.elements[i].name=='flrjockeyid[]') { theForm.elements[i].checked = a; }}}
function selectl(a) { var theForm = document.qsform; for (i=0; i<theForm.elements.length; i++) {  if (theForm.elements[i].name=='winjockeyid[]') { theForm.elements[i].checked = a; }}}
function selectm(a) { var theForm = document.qsform; for (i=0; i<theForm.elements.length; i++) {  if (theForm.elements[i].name=='trainerid[]') { theForm.elements[i].checked = a; }}}
function selectn(a) { var theForm = document.qsform; for (i=0; i<theForm.elements.length; i++) {  if (theForm.elements[i].name=='prevtrainerid[]') { theForm.elements[i].checked = a; }}}
function selecto(a) { var theForm = document.qsform; for (i=0; i<theForm.elements.length; i++) {  if (theForm.elements[i].name=='slrtrainerid[]') { theForm.elements[i].checked = a; }}}
function selectp(a) { var theForm = document.qsform; for (i=0; i<theForm.elements.length; i++) {  if (theForm.elements[i].name=='tlrtrainerid[]') { theForm.elements[i].checked = a; }}}
function selectq(a) { var theForm = document.qsform; for (i=0; i<theForm.elements.length; i++) {  if (theForm.elements[i].name=='flrtrainerid[]') { theForm.elements[i].checked = a; }}}
function selectr(a) { var theForm = document.qsform; for (i=0; i<theForm.elements.length; i++) {  if (theForm.elements[i].name=='wintrainerid[]') { theForm.elements[i].checked = a; }}}
function selects(a) { var theForm = document.qsform; for (i=0; i<theForm.elements.length; i++) {  if (theForm.elements[i].name=='formstallion[]') { theForm.elements[i].checked = a; }}}
function selectt(a) { var theForm = document.qsform; for (i=0; i<theForm.elements.length; i++) {  if (theForm.elements[i].name=='formprevplaceid[]') { theForm.elements[i].checked = a; }}}
function selectu(a) { var theForm = document.qsform; for (i=0; i<theForm.elements.length; i++) {  if (theForm.elements[i].name=='formslrplaceid[]') { theForm.elements[i].checked = a; }}}
function selectv(a) { var theForm = document.qsform; for (i=0; i<theForm.elements.length; i++) {  if (theForm.elements[i].name=='formtlrplaceid[]') { theForm.elements[i].checked = a; }}}
function selectw(a) { var theForm = document.qsform; for (i=0; i<theForm.elements.length; i++) {  if (theForm.elements[i].name=='formflrplaceid[]') { theForm.elements[i].checked = a; }}}
function getItem(id) { var itm = false; if(document.getElementById) { itm = document.getElementById(id); } if(document.all) { itm = document.all[id]; } if(document.layers) { itm = document.layers[id]; } return itm; }
function toggleItem(id) { itm = getItem(id); if(!itm) { return false; } if(itm.style.display == 'none') { itm.style.display = ''; } else { itm.style.display = 'none'; } return false; }
</script>

<link rel="apple-touch-icon" href="apple-touch-icon.png" />
<link rel="apple-touch-icon-precomposed" href="apple-touch-icon-precomposed.png" />
<link rel="apple-touch-icon-72x72" href="apple-touch-icon-72x72.png" />
<link rel="apple-touch-icon-72x72-precomposed" href="apple-touch-icon-72x72-precomposed.png" />

</head>
<body><link rel='stylesheet' type='text/css' href='stylesheet.css' />							
<table width=1024 align=center><tr valign='top'><td width=45%><a href='index.php'><img border=0 src='images/logo.jpg'></a>
<table cellpadding=4><tr><td valign=top class=small><form action='horsebase1.php' method='post'>
<b>Login</b> <input type='textbox' name='login' size=9> <b>Password </b><input type='password' name='password' size=9>
<input class='weebutton' type='submit' value='GO!'></form></td><td valign=top class=small2><a href='lostdetails.php'>Forgot?</a><br><a href='subscribe.php'>Free Trial</a></td></tr></table></td><td width=55% valign=top align=center>

<table width=100%><tr><td><form name='myform555' action='#'><select title='View Race Card' name='mylist555' onChange='nav555()'><option>TODAYS CARDS</option><option value='horse-racing-today.php?raceid=23657'>2.00 Worcester</option><option value='horse-racing-today.php?raceid=23629'>2.10 Ayr</option><option value='horse-racing-today.php?raceid=23637'>2.20 Exeter</option><option value='horse-racing-today.php?raceid=23658'>2.30 Worcester</option><option value='horse-racing-today.php?raceid=23630'>2.40 Ayr</option><option value='horse-racing-today.php?raceid=23643'>2.45 Tramore</option><option value='horse-racing-today.php?raceid=23638'>2.50 Exeter</option><option value='horse-racing-today.php?raceid=23659'>3.00 Worcester</option><option value='horse-racing-today.php?raceid=23631'>3.10 Ayr</option><option value='horse-racing-today.php?raceid=23644'>3.15 Tramore</option><option value='horse-racing-today.php?raceid=23639'>3.20 Exeter</option><option value='horse-racing-today.php?raceid=23660'>3.30 Worcester</option><option value='horse-racing-today.php?raceid=23632'>3.40 Ayr</option><option value='horse-racing-today.php?raceid=23645'>3.45 Tramore</option><option value='horse-racing-today.php?raceid=23640'>3.50 Exeter</option><option value='horse-racing-today.php?raceid=23661'>4.00 Worcester</option><option value='horse-racing-today.php?raceid=23633'>4.10 Ayr</option><option value='horse-racing-today.php?raceid=23646'>4.15 Tramore</option><option value='horse-racing-today.php?raceid=23641'>4.20 Exeter</option><option value='horse-racing-today.php?raceid=23662'>4.30 Worcester</option><option value='horse-racing-today.php?raceid=23634'>4.40 Ayr</option><option value='horse-racing-today.php?raceid=23647'>4.45 Tramore</option><option value='horse-racing-today.php?raceid=23642'>4.50 Exeter</option><option value='horse-racing-today.php?raceid=23663'>5.00 Worcester</option><option value='horse-racing-today.php?raceid=23635'>5.10 Ayr</option><option value='horse-racing-today.php?raceid=23648'>5.15 Tramore</option><option value='horse-racing-today.php?raceid=23650'>5.20 Wolverhampton</option><option value='horse-racing-today.php?raceid=23636'>5.40 Ayr</option><option value='horse-racing-today.php?raceid=23649'>5.45 Tramore</option><option value='horse-racing-today.php?raceid=23651'>5.50 Wolverhampton</option><option value='horse-racing-today.php?raceid=23652'>6.20 Wolverhampton</option><option value='horse-racing-today.php?raceid=23653'>6.50 Wolverhampton</option><option value='horse-racing-today.php?raceid=23654'>7.20 Wolverhampton</option><option value='horse-racing-today.php?raceid=23655'>7.50 Wolverhampton</option><option value='horse-racing-today.php?raceid=23656'>8.20 Wolverhampton</option></select></form></td>
<td><form name='myform556' action='#'><select title='View Site Pages' name='mylist556' onChange='nav556()'><option>SITE NAVIGATION</option>
<option value='horsebase1.php'>---MY HRB---</option><option value='donate.php'>Make A Donation</option><option value='newsharedsystems.php'>Members Shared Systems</option><option value='horsebase3.php'>My Account Settings</option><option value='horsebase4.php'>My Horses Management</option><option value='horsenotes.php'>My Notes Management</option><option value='horsebase_qualifiers.php'>My Qualifiers</option><option value='horsebase_qualifiersv4.php'>My Qualifiers V4 (Beta)</option><option value='horsebase6.php'>My Races Management</option><option value='horsebase5.php'>My Report</option><option value='horsebase2_oldstyle.php'>My Systems (Old Style)</option><option value='horsebase2.php'>My Systems Management</option><option value='horsebase7.php'>My Trends Management</option><option value='horsebase2_why.php'>Qualifiers Confirmation Check</option><option value='horse-racing-today.php'>---DAILY CARDS and TOOLS---</option><option value='horse-racing-today.php'>Todays Cards & Analysis</option><option value='atoz.php'>A-Z of Horses Running</option><option value='dailyjockeys.php'>Jockeys Report</option><option value='dailydistance.php'>Last 10 Distances Report</option><option value='nonrunners.php'>Non Runners</option><option value='liveoddstracker.php'>Odds Tracker</option><option value='dailyoffrat.php'>Official Ratings Report</option><option value='onedayracecards.php'>One Day Race Cards</option><option value='ratingsmachinev2-multiraceview.php'>One Day Ratings</option><option value='shortcuts.php'>Shortcuts</option><option value='statattackextrastallion.php'>Stallion Stat Attack Extra</option><option value='statattack.php'>Stat Attack</option><option value='statattack-profiler.php'>Stat Attack Extra</option><option value='dailytrainers.php'>Trainers Report</option><option value='dailyweight.php'>Weight Report</option><option value='research.php'>---RESEARCH TOOLS---</option><option value='systemwizard2.php?showset=1'>System Builder</option>
<option value='ratingsmachinev2.php'>Ratings Machine</option><option value='racehistoriesmenu.php'>Big Race Trends</option><option value='collateralformtool.php'>Collateral Form Tool</option><option value='search.php'>Database Search</option><option value='profiler.php'>Going, Distance and Month Statistics</option><option value='hotraces.php'>Hot/Cold Races</option><option value='oddswatch.php'>Odds Watch</option><option value='horse-racing-results.php'>Results Database</option><option value='systemsimplestats.php'>Simple Stats</option><option value='horse-racing-special.php'>Special</option><option value='stalls.php'>Stalls Analyser</option><option value='horse-racing-statistics.php'>Statistics</option><option value='horse-racing-tracks.php'>Tracks - Help & Information</option><option value='helpsection.php'>---HELP & INFO---</option><option value='systems-article2.php'>13 key factors of system building</option><option value='about.php'>About HorseRaceBase</option><option value='betfair-horse-racing.php'>Betfair Betting Exchange</option><option value='contact.php'>Contact Us</option><option value='customised-solutions.php'>Customised Service</option><option value='disclaimer.php'>Disclaimer</option><option value='horse-racing-distances.php'>Distances Information & Help</option><option value='systems-article1.php'>Exploring Jockey Systems</option><option value='horse-racing-websites.php'>External Links</option><option value='horse-racing-favourites.php'>Favourites Information & Help</option><option value='horse-racing-fixtures.php'>Fixture List</option><option value='horse-racing-form.php'>Form Study Help & Information</option><option value='faq.php'>Frequently Asked Questions</option><option value='horse-racing-terms.php'>Glossary of Terms</option><option value='horse-racing-going.php'>Going Information & Help</option><option value='helpsection.php'>Help</option><option value='horse-racing-history.php'>History of Horse Racing </option><option value='horse-racing-blog.php'>Horse Racing Blog</option><option value='horse-racing-data.php'>Horse Racing Data</option><option value='horse-racing-horses-index.php'>Horses Index</option><option value='horse-racing-jockeys.php'>Jockeys Help & Information</option><option value='horse-racing-jockeys-index.php'>Jockeys Index</option><option value='feedback.php'>Members Feedback Form</option><option value='exceltips.php'>Microsoft Excel User Tips</option><option value='horse-racing-odds.php'>Odds Help & information</option><option value='horse-racing-software.php'>Overview - Daily Horse Racing Tools</option><option value='horse-racing-management.php'>Overview - Horse Racing Management Tools</option><option value='horse-racing-research.php'>Overview - Horse Racing Research Tools</option><option value='horse-racing-place.php'>Placing Information and Help</option><option value='horse-racing-ratings.php'>Ratings Information & Help</option><option value='recommend-a-friend.php'>Recommend a Friend</option><option value='lostdetails.php'>Recover Lost Login Details</option><option value='horse-racing-information.php'>Site Map, Help & Information</option><option value='horse-racing-stallions.php'>Stallions Help & Information Page</option><option value='horse-racing-stallions-index.php'>Stallions Index</option><option value='horse-racing-systems.php'>Systems Information and Help</option><option value='testimonials.php'>Testimonials</option><option value='horse-racing-trainers-index.php'>Trainers Index</option><option value='horse-racing-trainers.php'>Trainers Information & help</option><option value='ratingsmachinehelppages2.php'>Understanding what ratings are</option><option value='v4simple.php'>Version 4 System Builder Fast Start</option><option value='v4help.php'>Version 4 System Builder Help Content</option><option value='horse-racing-weight.php'>Weight Information & help</option><option value='index.php'>Visitors Home</option><option value='horse-racing-games.php'>---Fun & Games---</option><option value='losing-horses.php'>7 Famous Odds-On Losing Horses</option><option value='cheltenham-festival-quiz.php'>Cheltenham Festival Quiz</option><option value='seconditis.php'>Seconditus - The League Tables</option><option value='spot-an-idiot-gambler.php'>Spot An Idiot Gambler</option></select></form></td><td> <form name=searchthis action=searchpage.php method=post><input size=14 type=text name='searchhunt' value='search database'
onclick="make_blank();"><input type=hidden name='searchtype' value=5></form></td></tr></table>


<table><tr><td>
<table id=menu1><tr><td><a href='horsebase1.php' onmouseover="mopen('m1')" onmouseout="mclosetime()">My HRB</a>
      <div id='m1' onmouseover='mcancelclosetime()' onmouseout='mclosetime()'>
<a href='horsebase1.php'>My HorseRaceBase</a><a href='horsebase_qualifiers.php'>My Qualifiers</a>
<a href='horsebase5.php'>My Report</a><a href='horsebase3.php'>My Account Settings</a>
<a href='horsebase2.php'>My Systems Management</a><a href='horsebase4.php'>My Horses Management</a><a href='horsebase6.php'>My Races Management</a>
<a href='horsebase7.php'>My Trends Management</a><a href='horsenotes.php'>My Notes Management</a><a href='donate.php'>Make A Donation</a>

</div>
</td></tr></table></td>

<td><table id=menu2><tr><td>
<a href='horse-racing-today.php' onmouseover="mopen('m2')" onmouseout="mclosetime()">Cards/Daily</a>
      <div id='m2' onmouseover='mcancelclosetime()' onmouseout='mclosetime()'>
<a href='horse-racing-today.php'>Todays Race Cards & Analysis</a>
<a href='statattack.php'>Stat Attack</a><a href='statattack-profiler.php'>Stat Attack Extra</a>
<a href='statattackextrastallion.php'>Stallion Stat Attack Extra</a>
<a href='shortcuts.php'>Shortcuts</a><a href='ratingsmachinev2-multiraceview.php'>One Day Ratings</a>
<a href='onedayracecards.php'>One Day Race Cards</a>
<a href='dailyjockeys.php'>Jockeys Report</a><a href='dailytrainers.php'>Trainers Report</a><a href='dailyoffrat.php'>Official Ratings Report</a>
<a href='dailyweight.php'>Weight Report</a><a href='dailydistance.php'>Last 10 Distances Report</a>
<a href='atoz.php'>A-Z of Runners</a><a href='nonrunners.php'>Non Runners</a><a href='liveoddstracker.php'>Odds Tracker</a>


        </div>
</td></tr></table></td>

<td><table id=menu1><tr><td>
<a href='horse-racing-results.php' onmouseover="mopen('m3')" onmouseout="mclosetime()">Results</a>
      <div id='m3' onmouseover='mcancelclosetime()' onmouseout='mclosetime()'>
<a href='horse-racing-results.php?racedate=2014-10-08'>Yesterdays Results</a><a href='horse-racing-results.php'>Results Search</a>
<a href='horse-racing-results.php?resultssearch=1'>Advanced Results Search</a>
</div></td></tr></table></td>

<td><table id=menu2><tr><td>
<a href='horse-racing-research.php' onmouseover="mopen('m4')" onmouseout="mclosetime()">Research</a>
      <div id='m4' onmouseover='mcancelclosetime()' onmouseout='mclosetime()'>
<a href='systemwizard2.php?showset=1'>System Builder</a><a href='ratingsmachinev2.php'>Ratings Machine</a>
<a href='horse-racing-statistics.php'>Statistics</a><a href='oddswatch.php'>Odds Watch</a>
<a href='hotraces.php'>Hot/Cold Races</a><a href='collateralformtool.php'>Collateral Form</a>
<a href='stalls.php'>Stalls Analyser</a><a href='racehistoriesmenu.php'>Big Race Trends</a>
<a href='horse-racing-tracks.php'>Tracks</a><a href='search.php'>Database Search</a>
</div>
</td></tr></table></td>

<td><table id=menu3><tr><td>
<a href='horse-racing-information.php' onmouseover="mopen('m5')" onmouseout="mclosetime()">HELP</a>
      <div id='m5' onmouseover='mcancelclosetime()' onmouseout='mclosetime()'>
<a href='horse-racing-information.php'>Site Directory</a><a href='faq.php'>F.A.Q</a><a href='helpsection.php#videos'>Video Tutorials</a>
</div>
</td></tr></table></td>


<td><table id=menu2><tr><td>
<a href='horse-racing-blog.php' onmouseover="mopen('m6')" onmouseout="mclosetime()">BETA/Blog</a>
      <div id='m6' onmouseover='mcancelclosetime()' onmouseout='mclosetime()'>
<a href='horse-racing-blog.php'>Chris's Blog</a>
<a target='_blank' href='v4builder.php'>V4 System Builder (BETA)</a>
<a target='_blank' href='v4advancequalifiers.php'>V4 Qualifiers (BETA)</a>
<a target='_blank' href='v4savedsystems.php'>V4 Saved Systems (BETA)</a>
<a target='_blank' href='v4savedtrends.php'>V4 Saved Trends (BETA)</a>
<a target='_blank' href='v4savedsystems.php?userchoicego=1'>V4 Performance Report (BETA)</a>
<a target='_blank' href='v4simple.php'>V4 Fast Start (BETA)</a>
<a target='_blank' href='v4help.php'>V4 Help Menu (BETA)</a>
<a target='_blank' href='v4setup.php'>V4 Customisation (BETA)</a>



</div>
</td></tr></table></td>




</tr></table>





</td></tr></table><table width=1024 align=center><tr><td width=100% valign=top>
<hr>












<p class=standard>You must hold a valid <a href='index.php'>HorseRaceBase</a> membership to access this feature.
<a href='subscribe.php'>Sign up for a free trial now</a></p>
<br><hr></td></tr></table>
<table width=1024 align=center><tr><td valign=top width=65%>
<p class=small2>This page loaded in 0 seconds. 
Help HorseRaceBase continue to expand!! Do you have a blog or website - add a link to HorseRaceBase. Tell others and 
benefit from the <a href='recommend-a-friend.php'>Recommend a Friend</a> scheme.</p>

<span class=small>Coming together is a beginning, Keeping together is progress, Working together is success. </span><br>
<span class=instruction6>Henry Ford</span>
</td>
<td valign=top align=center width=35%>
<table width=100%><tr class=breadcrumb><td><a href="about.php">About Us</a></td>
<td><a href="horse-racing-information.php">Site Map</a></td>
<td><a href="contact.php">Contact</a> </td>
<td><a href="disclaimer.php">Disclaimer</a></td></tr></table>                              
<a href='http://twitter.com/horseracebase'>
<img src="images/twitter.jpg" alt='HorseRaceBAse on Twitter' border=0></a>
</td></tr></table>

</body></html>

Open in new window

0
Julian HansenCommented:
@runnerjp - did you try the code I posted above? You just need to change the line where I read the HTML from a file to whatever method you use to get the html into the $content variable.

The code posted should do what you required.
0
Ray PaseurCommented:
The sample HTML does not contain the signal string.  Sometimes the quality of the answer is highly dependent on the quality of the test data!  Actually, I shouldn't say "sometimes."  I should say "Always!"

http://iconoun.com/demo/temp_runnerjp2005.php

<?php // demo/temp_runnerjp.php
error_reporting(E_ALL);

// SEE: http://www.experts-exchange.com/Programming/Languages/Scripting/PHP/Q_28533808.html#a40369207
// REF: if the table contains td[contains(@class, "databreakdown")] then grab the whole table!

// SIMULATE READING THE DATA FROM AN EXTERNAL URL OR FILE
$htm = <<<EOD
<html><head><title>Newly Refurbished Genting Casino Brighton Handicap - Race Result - 7th Oct 2014</title>
<meta name="google-site-verification" content="p9VK7t1lSqJAOs1KEsivev9xf0-72tTB-UY8fQm9sXw" />
<meta name='description' content='Brighton - 7th Oct 2014 - Newly Refurbished Genting Casino Brighton Handicap '>
<script type="text/javascript">
var timeout = 500;
var closetimer = 0;
var ddmenuitem = 0;
function make_blank() { document.searchthis.searchhunt.value = ""; }
function make_blank2() { document.ss.systemname.value = ""; }
function nav() { var w = document.myform.mylist.selectedIndex; var url_add = document.myform.mylist.options[w].value; window.location.href = url_add; }
function nav2() { var w = document.myform2.mylist2.selectedIndex; var url_add = document.myform2.mylist2.options[w].value; window.location.href = url_add; }
function nav3() { var w = document.myform3.mylist3.selectedIndex; var url_add = document.myform3.mylist3.options[w].value; window.location.href = url_add; }
function nav4() { var w = document.myform4.mylist4.selectedIndex; var url_add = document.myform4.mylist4.options[w].value; window.location.href = url_add; }
function nav5() { var w = document.myform5.mylist5.selectedIndex; var url_add = document.myform5.mylist5.options[w].value; window.location.href = url_add; }
function nav6() { var w = document.myform6.mylist6.selectedIndex; var url_add = document.myform6.mylist6.options[w].value; window.location.href = url_add; }
function nav555() { var w = document.myform555.mylist555.selectedIndex; var url_add = document.myform555.mylist555.options[w].value; window.location.href = url_add; }
function nav556() { var w = document.myform556.mylist556.selectedIndex; var url_add = document.myform556.mylist556.options[w].value; window.location.href = url_add; }
function go(loc) { window.location.href = loc; }
function mopen(id) { mcancelclosetime(); if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';	ddmenuitem = document.getElementById(id); ddmenuitem.style.visibility = 'visible'; }
function mclose() { if(ddmenuitem) ddmenuitem.style.visibility = 'hidden'; }
function mclosetime() {	closetimer = window.setTimeout(mclose, timeout); }
function mcancelclosetime() { if(closetimer) { window.clearTimeout(closetimer); closetimer = null; }}
document.onclick = mclose;
function select(a) { var theForm = document.qsform; for (i=0; i<theForm.elements.length; i++) {  if (theForm.elements[i].name=='formtrackid[]') { theForm.elements[i].checked = a; }}}
function selectb(a) { var theForm = document.qsform; for (i=0; i<theForm.elements.length; i++) {  if (theForm.elements[i].name=='formprevtrackid[]') { theForm.elements[i].checked = a; }}}
function selectc(a) { var theForm = document.qsform; for (i=0; i<theForm.elements.length; i++) {  if (theForm.elements[i].name=='formslrtrackid[]') { theForm.elements[i].checked = a; }}}
function selectd(a) { var theForm = document.qsform; for (i=0; i<theForm.elements.length; i++) {  if (theForm.elements[i].name=='formtlrtrackid[]') { theForm.elements[i].checked = a; }}}
function selecte(a) { var theForm = document.qsform; for (i=0; i<theForm.elements.length; i++) {  if (theForm.elements[i].name=='formflrtrackid[]') { theForm.elements[i].checked = a; }}}
function selectf(a) { var theForm = document.qsform; for (i=0; i<theForm.elements.length; i++) {  if (theForm.elements[i].name=='formwintrackid[]') { theForm.elements[i].checked = a; }}}
function selectg(a) { var theForm = document.qsform; for (i=0; i<theForm.elements.length; i++) {  if (theForm.elements[i].name=='jockeyid[]') { theForm.elements[i].checked = a; }}}
function selecth(a) { var theForm = document.qsform; for (i=0; i<theForm.elements.length; i++) {  if (theForm.elements[i].name=='prevjockeyid[]') { theForm.elements[i].checked = a; }}}
function selecti(a) { var theForm = document.qsform; for (i=0; i<theForm.elements.length; i++) {  if (theForm.elements[i].name=='slrjockeyid[]') { theForm.elements[i].checked = a; }}}
function selectj(a) { var theForm = document.qsform; for (i=0; i<theForm.elements.length; i++) {  if (theForm.elements[i].name=='tlrjockeyid[]') { theForm.elements[i].checked = a; }}}
function selectk(a) { var theForm = document.qsform; for (i=0; i<theForm.elements.length; i++) {  if (theForm.elements[i].name=='flrjockeyid[]') { theForm.elements[i].checked = a; }}}
function selectl(a) { var theForm = document.qsform; for (i=0; i<theForm.elements.length; i++) {  if (theForm.elements[i].name=='winjockeyid[]') { theForm.elements[i].checked = a; }}}
function selectm(a) { var theForm = document.qsform; for (i=0; i<theForm.elements.length; i++) {  if (theForm.elements[i].name=='trainerid[]') { theForm.elements[i].checked = a; }}}
function selectn(a) { var theForm = document.qsform; for (i=0; i<theForm.elements.length; i++) {  if (theForm.elements[i].name=='prevtrainerid[]') { theForm.elements[i].checked = a; }}}
function selecto(a) { var theForm = document.qsform; for (i=0; i<theForm.elements.length; i++) {  if (theForm.elements[i].name=='slrtrainerid[]') { theForm.elements[i].checked = a; }}}
function selectp(a) { var theForm = document.qsform; for (i=0; i<theForm.elements.length; i++) {  if (theForm.elements[i].name=='tlrtrainerid[]') { theForm.elements[i].checked = a; }}}
function selectq(a) { var theForm = document.qsform; for (i=0; i<theForm.elements.length; i++) {  if (theForm.elements[i].name=='flrtrainerid[]') { theForm.elements[i].checked = a; }}}
function selectr(a) { var theForm = document.qsform; for (i=0; i<theForm.elements.length; i++) {  if (theForm.elements[i].name=='wintrainerid[]') { theForm.elements[i].checked = a; }}}
function selects(a) { var theForm = document.qsform; for (i=0; i<theForm.elements.length; i++) {  if (theForm.elements[i].name=='formstallion[]') { theForm.elements[i].checked = a; }}}
function selectt(a) { var theForm = document.qsform; for (i=0; i<theForm.elements.length; i++) {  if (theForm.elements[i].name=='formprevplaceid[]') { theForm.elements[i].checked = a; }}}
function selectu(a) { var theForm = document.qsform; for (i=0; i<theForm.elements.length; i++) {  if (theForm.elements[i].name=='formslrplaceid[]') { theForm.elements[i].checked = a; }}}
function selectv(a) { var theForm = document.qsform; for (i=0; i<theForm.elements.length; i++) {  if (theForm.elements[i].name=='formtlrplaceid[]') { theForm.elements[i].checked = a; }}}
function selectw(a) { var theForm = document.qsform; for (i=0; i<theForm.elements.length; i++) {  if (theForm.elements[i].name=='formflrplaceid[]') { theForm.elements[i].checked = a; }}}
function getItem(id) { var itm = false; if(document.getElementById) { itm = document.getElementById(id); } if(document.all) { itm = document.all[id]; } if(document.layers) { itm = document.layers[id]; } return itm; }
function toggleItem(id) { itm = getItem(id); if(!itm) { return false; } if(itm.style.display == 'none') { itm.style.display = ''; } else { itm.style.display = 'none'; } return false; }
</script>

<link rel="apple-touch-icon" href="apple-touch-icon.png" />
<link rel="apple-touch-icon-precomposed" href="apple-touch-icon-precomposed.png" />
<link rel="apple-touch-icon-72x72" href="apple-touch-icon-72x72.png" />
<link rel="apple-touch-icon-72x72-precomposed" href="apple-touch-icon-72x72-precomposed.png" />

</head>
<body><link rel='stylesheet' type='text/css' href='stylesheet.css' />
<table width=1024 align=center><tr valign='top'><td width=45%><a href='index.php'><img border=0 src='images/logo.jpg'></a>
<table cellpadding=4><tr><td valign=top class=small><form action='horsebase1.php' method='post'>
<b>Login</b> <input type='textbox' name='login' size=9> <b>Password </b><input type='password' name='password' size=9>
<input class='weebutton' type='submit' value='GO!'></form></td><td valign=top class=small2><a href='lostdetails.php'>Forgot?</a><br><a href='subscribe.php'>Free Trial</a></td></tr></table></td><td width=55% valign=top align=center>

<table width=100%><tr><td><form name='myform555' action='#'><select title='View Race Card' name='mylist555' onChange='nav555()'><option>TODAYS CARDS</option><option value='horse-racing-today.php?raceid=23657'>2.00 Worcester</option><option value='horse-racing-today.php?raceid=23629'>2.10 Ayr</option><option value='horse-racing-today.php?raceid=23637'>2.20 Exeter</option><option value='horse-racing-today.php?raceid=23658'>2.30 Worcester</option><option value='horse-racing-today.php?raceid=23630'>2.40 Ayr</option><option value='horse-racing-today.php?raceid=23643'>2.45 Tramore</option><option value='horse-racing-today.php?raceid=23638'>2.50 Exeter</option><option value='horse-racing-today.php?raceid=23659'>3.00 Worcester</option><option value='horse-racing-today.php?raceid=23631'>3.10 Ayr</option><option value='horse-racing-today.php?raceid=23644'>3.15 Tramore</option><option value='horse-racing-today.php?raceid=23639'>3.20 Exeter</option><option value='horse-racing-today.php?raceid=23660'>3.30 Worcester</option><option value='horse-racing-today.php?raceid=23632'>3.40 Ayr</option><option value='horse-racing-today.php?raceid=23645'>3.45 Tramore</option><option value='horse-racing-today.php?raceid=23640'>3.50 Exeter</option><option value='horse-racing-today.php?raceid=23661'>4.00 Worcester</option><option value='horse-racing-today.php?raceid=23633'>4.10 Ayr</option><option value='horse-racing-today.php?raceid=23646'>4.15 Tramore</option><option value='horse-racing-today.php?raceid=23641'>4.20 Exeter</option><option value='horse-racing-today.php?raceid=23662'>4.30 Worcester</option><option value='horse-racing-today.php?raceid=23634'>4.40 Ayr</option><option value='horse-racing-today.php?raceid=23647'>4.45 Tramore</option><option value='horse-racing-today.php?raceid=23642'>4.50 Exeter</option><option value='horse-racing-today.php?raceid=23663'>5.00 Worcester</option><option value='horse-racing-today.php?raceid=23635'>5.10 Ayr</option><option value='horse-racing-today.php?raceid=23648'>5.15 Tramore</option><option value='horse-racing-today.php?raceid=23650'>5.20 Wolverhampton</option><option value='horse-racing-today.php?raceid=23636'>5.40 Ayr</option><option value='horse-racing-today.php?raceid=23649'>5.45 Tramore</option><option value='horse-racing-today.php?raceid=23651'>5.50 Wolverhampton</option><option value='horse-racing-today.php?raceid=23652'>6.20 Wolverhampton</option><option value='horse-racing-today.php?raceid=23653'>6.50 Wolverhampton</option><option value='horse-racing-today.php?raceid=23654'>7.20 Wolverhampton</option><option value='horse-racing-today.php?raceid=23655'>7.50 Wolverhampton</option><option value='horse-racing-today.php?raceid=23656'>8.20 Wolverhampton</option></select></form></td>
<td><form name='myform556' action='#'><select title='View Site Pages' name='mylist556' onChange='nav556()'><option>SITE NAVIGATION</option>
<option value='horsebase1.php'>---MY HRB---</option><option value='donate.php'>Make A Donation</option><option value='newsharedsystems.php'>Members Shared Systems</option><option value='horsebase3.php'>My Account Settings</option><option value='horsebase4.php'>My Horses Management</option><option value='horsenotes.php'>My Notes Management</option><option value='horsebase_qualifiers.php'>My Qualifiers</option><option value='horsebase_qualifiersv4.php'>My Qualifiers V4 (Beta)</option><option value='horsebase6.php'>My Races Management</option><option value='horsebase5.php'>My Report</option><option value='horsebase2_oldstyle.php'>My Systems (Old Style)</option><option value='horsebase2.php'>My Systems Management</option><option value='horsebase7.php'>My Trends Management</option><option value='horsebase2_why.php'>Qualifiers Confirmation Check</option><option value='horse-racing-today.php'>---DAILY CARDS and TOOLS---</option><option value='horse-racing-today.php'>Todays Cards & Analysis</option><option value='atoz.php'>A-Z of Horses Running</option><option value='dailyjockeys.php'>Jockeys Report</option><option value='dailydistance.php'>Last 10 Distances Report</option><option value='nonrunners.php'>Non Runners</option><option value='liveoddstracker.php'>Odds Tracker</option><option value='dailyoffrat.php'>Official Ratings Report</option><option value='onedayracecards.php'>One Day Race Cards</option><option value='ratingsmachinev2-multiraceview.php'>One Day Ratings</option><option value='shortcuts.php'>Shortcuts</option><option value='statattackextrastallion.php'>Stallion Stat Attack Extra</option><option value='statattack.php'>Stat Attack</option><option value='statattack-profiler.php'>Stat Attack Extra</option><option value='dailytrainers.php'>Trainers Report</option><option value='dailyweight.php'>Weight Report</option><option value='research.php'>---RESEARCH TOOLS---</option><option value='systemwizard2.php?showset=1'>System Builder</option>
<option value='ratingsmachinev2.php'>Ratings Machine</option><option value='racehistoriesmenu.php'>Big Race Trends</option><option value='collateralformtool.php'>Collateral Form Tool</option><option value='search.php'>Database Search</option><option value='profiler.php'>Going, Distance and Month Statistics</option><option value='hotraces.php'>Hot/Cold Races</option><option value='oddswatch.php'>Odds Watch</option><option value='horse-racing-results.php'>Results Database</option><option value='systemsimplestats.php'>Simple Stats</option><option value='horse-racing-special.php'>Special</option><option value='stalls.php'>Stalls Analyser</option><option value='horse-racing-statistics.php'>Statistics</option><option value='horse-racing-tracks.php'>Tracks - Help & Information</option><option value='helpsection.php'>---HELP & INFO---</option><option value='systems-article2.php'>13 key factors of system building</option><option value='about.php'>About HorseRaceBase</option><option value='betfair-horse-racing.php'>Betfair Betting Exchange</option><option value='contact.php'>Contact Us</option><option value='customised-solutions.php'>Customised Service</option><option value='disclaimer.php'>Disclaimer</option><option value='horse-racing-distances.php'>Distances Information & Help</option><option value='systems-article1.php'>Exploring Jockey Systems</option><option value='horse-racing-websites.php'>External Links</option><option value='horse-racing-favourites.php'>Favourites Information & Help</option><option value='horse-racing-fixtures.php'>Fixture List</option><option value='horse-racing-form.php'>Form Study Help & Information</option><option value='faq.php'>Frequently Asked Questions</option><option value='horse-racing-terms.php'>Glossary of Terms</option><option value='horse-racing-going.php'>Going Information & Help</option><option value='helpsection.php'>Help</option><option value='horse-racing-history.php'>History of Horse Racing </option><option value='horse-racing-blog.php'>Horse Racing Blog</option><option value='horse-racing-data.php'>Horse Racing Data</option><option value='horse-racing-horses-index.php'>Horses Index</option><option value='horse-racing-jockeys.php'>Jockeys Help & Information</option><option value='horse-racing-jockeys-index.php'>Jockeys Index</option><option value='feedback.php'>Members Feedback Form</option><option value='exceltips.php'>Microsoft Excel User Tips</option><option value='horse-racing-odds.php'>Odds Help & information</option><option value='horse-racing-software.php'>Overview - Daily Horse Racing Tools</option><option value='horse-racing-management.php'>Overview - Horse Racing Management Tools</option><option value='horse-racing-research.php'>Overview - Horse Racing Research Tools</option><option value='horse-racing-place.php'>Placing Information and Help</option><option value='horse-racing-ratings.php'>Ratings Information & Help</option><option value='recommend-a-friend.php'>Recommend a Friend</option><option value='lostdetails.php'>Recover Lost Login Details</option><option value='horse-racing-information.php'>Site Map, Help & Information</option><option value='horse-racing-stallions.php'>Stallions Help & Information Page</option><option value='horse-racing-stallions-index.php'>Stallions Index</option><option value='horse-racing-systems.php'>Systems Information and Help</option><option value='testimonials.php'>Testimonials</option><option value='horse-racing-trainers-index.php'>Trainers Index</option><option value='horse-racing-trainers.php'>Trainers Information & help</option><option value='ratingsmachinehelppages2.php'>Understanding what ratings are</option><option value='v4simple.php'>Version 4 System Builder Fast Start</option><option value='v4help.php'>Version 4 System Builder Help Content</option><option value='horse-racing-weight.php'>Weight Information & help</option><option value='index.php'>Visitors Home</option><option value='horse-racing-games.php'>---Fun & Games---</option><option value='losing-horses.php'>7 Famous Odds-On Losing Horses</option><option value='cheltenham-festival-quiz.php'>Cheltenham Festival Quiz</option><option value='seconditis.php'>Seconditus - The League Tables</option><option value='spot-an-idiot-gambler.php'>Spot An Idiot Gambler</option></select></form></td><td> <form name=searchthis action=searchpage.php method=post><input size=14 type=text name='searchhunt' value='search database'
onclick="make_blank();"><input type=hidden name='searchtype' value=5></form></td></tr></table>


<table><tr><td>
<table id=menu1><tr><td><a href='horsebase1.php' onmouseover="mopen('m1')" onmouseout="mclosetime()">My HRB</a>
      <div id='m1' onmouseover='mcancelclosetime()' onmouseout='mclosetime()'>
<a href='horsebase1.php'>My HorseRaceBase</a><a href='horsebase_qualifiers.php'>My Qualifiers</a>
<a href='horsebase5.php'>My Report</a><a href='horsebase3.php'>My Account Settings</a>
<a href='horsebase2.php'>My Systems Management</a><a href='horsebase4.php'>My Horses Management</a><a href='horsebase6.php'>My Races Management</a>
<a href='horsebase7.php'>My Trends Management</a><a href='horsenotes.php'>My Notes Management</a><a href='donate.php'>Make A Donation</a>

</div>
</td></tr></table></td>

<td><table id=menu2><tr><td>
<a href='horse-racing-today.php' onmouseover="mopen('m2')" onmouseout="mclosetime()">Cards/Daily</a>
      <div id='m2' onmouseover='mcancelclosetime()' onmouseout='mclosetime()'>
<a href='horse-racing-today.php'>Todays Race Cards & Analysis</a>
<a href='statattack.php'>Stat Attack</a><a href='statattack-profiler.php'>Stat Attack Extra</a>
<a href='statattackextrastallion.php'>Stallion Stat Attack Extra</a>
<a href='shortcuts.php'>Shortcuts</a><a href='ratingsmachinev2-multiraceview.php'>One Day Ratings</a>
<a href='onedayracecards.php'>One Day Race Cards</a>
<a href='dailyjockeys.php'>Jockeys Report</a><a href='dailytrainers.php'>Trainers Report</a><a href='dailyoffrat.php'>Official Ratings Report</a>
<a href='dailyweight.php'>Weight Report</a><a href='dailydistance.php'>Last 10 Distances Report</a>
<a href='atoz.php'>A-Z of Runners</a><a href='nonrunners.php'>Non Runners</a><a href='liveoddstracker.php'>Odds Tracker</a>


        </div>
</td></tr></table></td>

<td><table id=menu1><tr><td>
<a href='horse-racing-results.php' onmouseover="mopen('m3')" onmouseout="mclosetime()">Results</a>
      <div id='m3' onmouseover='mcancelclosetime()' onmouseout='mclosetime()'>
<a href='horse-racing-results.php?racedate=2014-10-08'>Yesterdays Results</a><a href='horse-racing-results.php'>Results Search</a>
<a href='horse-racing-results.php?resultssearch=1'>Advanced Results Search</a>
</div></td></tr></table></td>

<td><table id=menu2><tr><td>
<a href='horse-racing-research.php' onmouseover="mopen('m4')" onmouseout="mclosetime()">Research</a>
      <div id='m4' onmouseover='mcancelclosetime()' onmouseout='mclosetime()'>
<a href='systemwizard2.php?showset=1'>System Builder</a><a href='ratingsmachinev2.php'>Ratings Machine</a>
<a href='horse-racing-statistics.php'>Statistics</a><a href='oddswatch.php'>Odds Watch</a>
<a href='hotraces.php'>Hot/Cold Races</a><a href='collateralformtool.php'>Collateral Form</a>
<a href='stalls.php'>Stalls Analyser</a><a href='racehistoriesmenu.php'>Big Race Trends</a>
<a href='horse-racing-tracks.php'>Tracks</a><a href='search.php'>Database Search</a>
</div>
</td></tr></table></td>

<td><table id=menu3><tr><td>
<a href='horse-racing-information.php' onmouseover="mopen('m5')" onmouseout="mclosetime()">HELP</a>
      <div id='m5' onmouseover='mcancelclosetime()' onmouseout='mclosetime()'>
<a href='horse-racing-information.php'>Site Directory</a><a href='faq.php'>F.A.Q</a><a href='helpsection.php#videos'>Video Tutorials</a>
</div>
</td></tr></table></td>


<td><table id=menu2><tr><td>
<a href='horse-racing-blog.php' onmouseover="mopen('m6')" onmouseout="mclosetime()">BETA/Blog</a>
      <div id='m6' onmouseover='mcancelclosetime()' onmouseout='mclosetime()'>
<a href='horse-racing-blog.php'>Chris's Blog</a>
<a target='_blank' href='v4builder.php'>V4 System Builder (BETA)</a>
<a target='_blank' href='v4advancequalifiers.php'>V4 Qualifiers (BETA)</a>
<a target='_blank' href='v4savedsystems.php'>V4 Saved Systems (BETA)</a>
<a target='_blank' href='v4savedtrends.php'>V4 Saved Trends (BETA)</a>
<a target='_blank' href='v4savedsystems.php?userchoicego=1'>V4 Performance Report (BETA)</a>
<a target='_blank' href='v4simple.php'>V4 Fast Start (BETA)</a>
<a target='_blank' href='v4help.php'>V4 Help Menu (BETA)</a>
<a target='_blank' href='v4setup.php'>V4 Customisation (BETA)</a>



</div>
</td></tr></table></td>




</tr></table>





</td></tr></table><table width=1024 align=center><tr><td width=100% valign=top>
<hr>












<p class=standard>You must hold a valid <a href='index.php'>HorseRaceBase</a> membership to access this feature.
<a href='subscribe.php'>Sign up for a free trial now</a></p>
<br><hr></td></tr></table>
<table width=1024 align=center><tr><td valign=top width=65%>
<p class=small2>This page loaded in 0 seconds.
Help HorseRaceBase continue to expand!! Do you have a blog or website - add a link to HorseRaceBase. Tell others and
benefit from the <a href='recommend-a-friend.php'>Recommend a Friend</a> scheme.</p>

<span class=small>Coming together is a beginning, Keeping together is progress, Working together is success. </span><br>
<span class=instruction6>Henry Ford</span>
</td>
<td valign=top align=center width=35%>
<table width=100%><tr class=breadcrumb><td><a href="about.php">About Us</a></td>
<td><a href="horse-racing-information.php">Site Map</a></td>
<td><a href="contact.php">Contact</a> </td>
<td><a href="disclaimer.php">Disclaimer</a></td></tr></table>
<a href='http://twitter.com/horseracebase'>
<img src="images/twitter.jpg" alt='HorseRaceBAse on Twitter' border=0></a>
</td></tr></table>

</body></html>
EOD;

// OUR REFERENCE POINTS
$clu = '<table';
$sig = 'databreakdown';

// BREAK THE DATA APART WITH THE "CLUE STRING"
$arr = explode($clu, $htm);
echo PHP_EOL . 'THERE ARE ' . count($arr) . ' TABLE TAGS IN THE INPUT DOCUMENT<br>';

// SEARCH EACH SUBSTRING FOR THE SIGNAL STRING
$out = array();
foreach ($arr as $txt)
{
    if (strpos($txt, $sig))
    {
        echo htmlentities($clu . $txt);
        $out[] = $clu . $txt;
    }
}
var_dump($out);

Open in new window

0
gr8gonzoConsultantCommented:
Sorry, I was away from my computer for a good chunk of yesterday.

My article on SimpleHTMLDom doesn't cover every feature that it has, since it has a lot of them. To navigate from a child node to its parent, you just get its parent node like this:

$parentnode = $childnode->parent ();

So if you had this:
<table>
  <tr>
    <td>

and $childnode was the <td>, then:

$tr = $childnode->parent(); // <td>'s parent is <tr>
$table = $tr->parent(); // <tr>'s parent is <table>

And if you wanted to dump that HTML, you just use the save() method on that node. For example, if you wanted to save the HTML into a variable for later:

$html_of_the_table = $table->save();

Or you could just display it:

echo $table->save();

All of the features of SimpleHTMLDom (along with examples) are in it's one-page manual here:
http://simplehtmldom.sourceforge.net/manual.htm
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
runnerjp2005Author Commented:
http://www.experts-exchange.com/Programming/Languages/Scripting/PHP/Q_28535162.html

i have created a new question on the same subject if you guys would be able to help
0
Julian HansenCommented:
Is this question still open or are you going to close it? It appears you are using code posted in this thread in the new question?
0
Julian HansenCommented:
@runnerjp2005 you used code my post in this thread in your solution shown in this thread

http://www.experts-exchange.com/Programming/Languages/Scripting/PHP/Q_28535162.html

Just wondering why my comment did not make it into the accepted solution?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.