Pages

Wednesday 31 July 2013

Zend Dom Query Examples


    $htmlData ='
    <h3>
      <img src="wow/img.jpg" /><a href="http://wow.com">wow link</a>
     </h3>
    <h3>
      <img src="wow/img.jpg" ><a href="http://wow.com">wow link2</a>
    </h3> ';

##########EXAMPLE1#############
$dom= new Zend_Dom_Query($htmlData);
     $results = $dom->query('h3>a');
     /*OUTPUT
Child Tag:
#text
wow link
http://wow.com$$$

Child Tag:
#text
wow link2
http://wow.com$$$   */

     foreach($results as $result){
      //echo $result->textContent;
      $children = $result->childNodes;
       if($children->length > 0){
       foreach($children as $c){
           echo "Child Tag: <br />";
           echo $c->nodeName."<br />";
           echo $c->nodeValue."<br />";
       }
  }

   echo $result->getAttribute('href')."$$$<br /><hr />";
     }
##########EXAMPLE1#############



##########EXAMPLE2#############    
 $dom= new Zend_Dom_Query($htmlData);
     $results = $dom->query('h3');    
   
     /*OUTPUT
     http://wow.com
     http://wow.com
     */
     foreach($results as $result){
      echo $result->getElementsByTagName('a')->item(0)->getAttribute('href'); echo "<br>";
     }
##########EXAMPLE2#############     

Tuesday 7 August 2012

Zend Auth

Zend_Auth
Zend_Auth is concerned only with authentication and not with authorization. Authentication is loosely defined as determining whether an entity actually is allowed or not.