Jump to content

Ignore HTML tag in one section but parse in another


codeinphp

Recommended Posts

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');
				}
				}		

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.