codeinphp Posted August 6, 2015 Share Posted August 6, 2015 I have some html being parsed where the particular tag and values show up two times in the html. I wish to ignore it in the first section but parse it in the next. The first instance occurs in a list. <ul> <li class="prog_1046598 clearfix"> <span class="prog_name">SHOW NAME</span> <span class="prog_info">SHOW INFOspan> </li> The second occurs within a class. Basically the only thing that is identical is the prog_name but my code still grabs this. <div class="prog_cols"> <span class="prog_name">SHOW1</span> <div class="prog_time">SHOW TIME</div> <div class="prog_desc">SHOW INFO.<br/> </div> My code is the following. Even though I am using the div class="col th" to parse thru, I still get the prog_name in the span class from the above section. Is there a way to keep this from happening? $cols=$xpath->query('//div[@class="col th"]'); $aclasses=$xpath->query('//a[@class="channel_sched_link"]'); $progname=$xpath->query('//span[@class="prog_name"]'); $progtime=$xpath->query('//div[@class="prog_time"]'); $progdesc=$xpath->query('//div[@class="prog_desc"]'); foreach ($cols as $col){ $xcid=$col->getElementsByTagName('a'); foreach($xcid as $cids){ $cid[]=$cids->getAttribute('data-channelid'); for($x=0; $x<count($cid); $x++){ foreach ($progname as $name){ $show[]=$name->nodeValue; } $scid[]=$cids->getAttribute('data-channelid'); } } Link to comment https://forums.phpfreaks.com/topic/297672-ignore-html-tag-in-one-section-but-parse-in-another/ Share on other sites More sharing options...
requinix Posted August 7, 2015 Share Posted August 7, 2015 Sounds like you should be locating //div[@class=prog_cols] first, then within each of those locating the three parts you want. Link to comment https://forums.phpfreaks.com/topic/297672-ignore-html-tag-in-one-section-but-parse-in-another/#findComment-1518198 Share on other sites More sharing options...
codeinphp Posted August 7, 2015 Author Share Posted August 7, 2015 Thank you I will try to parse it with that in mind. Link to comment https://forums.phpfreaks.com/topic/297672-ignore-html-tag-in-one-section-but-parse-in-another/#findComment-1518205 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.