phpDocumentor php4-html-dom
[ class tree: php4-html-dom ] [ index: php4-html-dom ] [ all elements ]

Class: htmlParser

Source Location: /php4-html-dom.php

Class htmlParser

Class Overview

HTML parser class

Responsibilities: Giving the user a one-stop-shopping access to all the features

Located in /php4-html-dom.php [line 146]



		
				Author(s):
		
		
		
Information Tags:

Properties

Methods

[ Top ]
Property Summary
string   $LastHtml   Last HTML that was parsed
int   $ParseOptions   Parser options
htmlNode   $RootNode   Instance of htmlNode representing the root node of the document

[ Top ]
Method Summary
htmlParser   htmlParser()   Constructor
htmlNode|NULL   &getElementById()   Find a single node by id case insensitive
htmlNode|NULL   &getElementByName()   Find a single node by name case insensitive
htmlNode|NULL   &getElementByTagName()   Find a single node by tag name case insensitive
array|NULL   getElementsById()   Find multiple nodes by id case insensitive
array|NULL   getElementsByName()   Find multiple nodes by name case insensitive
array|NULL   getElementsByTagName()   Find multiple nodes by name case insensitive
string   getHtml()   Read the current HTML
void   parse()   Parse an HTML string

[ Top ]
Properties
string   $LastHtml = NULL [line 156]

Last HTML that was parsed


[ Top ]
int   $ParseOptions = poNone [line 162]

Parser options

API Tags:
See:  $GLOBALS[gHtmlParser]['parseOptions']


[ Top ]
htmlNode   $RootNode = NULL [line 151]

Instance of htmlNode representing the root node of the document


[ Top ]
Methods
Constructor htmlParser  [line 176]

  htmlParser htmlParser( )

Constructor

Example:

  1.    require_ones'php4-html-dom.php' );
  2.    $myParser new htmlParser();


API Tags:
Access:  public


[ Top ]
getElementById  [line 263]

  htmlNode|NULL &getElementById( string $aId  )

Find a single node by id case insensitive

Source:

  1. function &getElementById$aId ){
  2.       if ($this->RootNode)
  3.           return $this->RootNode->findNodeByAttributeDown'id'$aId );
  4.         else
  5.           return NULL;
  6.     }

Example:
  1.  $myNode =$myParser->getElementById'logo' );
  2.  if (isset($myNode))
  3.    echo htmlspecialchars$myNode->getHtml());

Parameters:
string   $aId:  Id attribute of node to be searched for

API Tags:
Access:  public


[ Top ]
getElementByName  [line 286]

  htmlNode|NULL &getElementByName( string $aName  )

Find a single node by name case insensitive

Source:

  1. function &getElementByName$aName ){
  2.       if ($this->RootNode)
  3.           return $this->RootNode->findNodeByAttributeDown'name'$aName );
  4.         else
  5.           return NULL;
  6.     }

Example:
  1.  $myTextInput =$myParser->getElementByName'firstName' );
  2.  if (isset($myTextInput))
  3.    echo htmlspecialchars$myTextInput->getHtml());

Parameters:
string   $aName:  Name attribute of node to be searched for

API Tags:
Access:  public


[ Top ]
getElementByTagName  [line 240]

  htmlNode|NULL &getElementByTagName( string $aTagName  )

Find a single node by tag name case insensitive

Source:

  1. function &getElementByTagName$aTagName ){
  2.       if ($this->RootNode)
  3.           return $this->RootNode->findNodeDown$aTagName );
  4.         else
  5.           return NULL;
  6.     }

Example:
  1.  $myNode =$myParser->getElementByTagName'div' );
  2.  if (isset($myNode))
  3.   echo $myNode->Attrubites['id'];

Parameters:
string   $aTagName:  Tag name of node to be searched for

API Tags:
Access:  public


[ Top ]
getElementsById  [line 338]

  array|NULL getElementsById( string $aId  )

Find multiple nodes by id case insensitive

Source:

  1. function getElementsById$aId ){
  2.       if ($this->RootNode{
  3.           $tempResult $this->RootNode->findNodesByAttributeDown'id'$aId );
  4.             if (count($tempResult)>0)
  5.               return $tempResult;
  6.             else
  7.               return NULL;
  8.         else
  9.           return NULL;
  10.     }

Example:
  1.  $myNodes $myParser->getElementsById'test' );
  2.  if (isset($myImages))
  3.    foreach$myNodes as $key => $obj )
  4.      echo htmlspecialchars$myNodes[$key]->getHtml());

Parameters:
string   $aId:  Id attribute of nodes to be searched for

API Tags:
Access:  public


[ Top ]
getElementsByName  [line 366]

  array|NULL getElementsByName( string $aName  )

Find multiple nodes by name case insensitive

Source:

  1. function getElementsByName$aName ){
  2.       if ($this->RootNode{
  3.           $tempResult $this->RootNode->findNodesByAttributeDown'name'$aName );
  4.             if (count($tempResult)>0)
  5.               return $tempResult;
  6.             else
  7.               return NULL;
  8.         else
  9.           return NULL;
  10.     }

Example:
  1.  $myControls $myParser->getElementsByName'zip' );
  2.  if (isset($myControls))
  3.    foreach$myControls as $key => $obj )
  4.      echo htmlspecialchars$myControls[$key]->getHtml());

Parameters:
string   $aName:  Name attribute of nodes to be searched for

API Tags:
Access:  public


[ Top ]
getElementsByTagName  [line 310]

  array|NULL getElementsByTagName( string $aTagName  )

Find multiple nodes by name case insensitive

Source:

  1. function getElementsByTagName$aTagName ){
  2.       if ($this->RootNode{
  3.           $tempResult $this->RootNode->findNodesDown$aTagName );
  4.             if (count($tempResult)>0)
  5.               return $tempResult;
  6.             else
  7.               return NULL;
  8.         else
  9.           return NULL;
  10.     }

Example:
  1.  $myNodes $myParser->getElementsByTagName'img' );
  2.  if (isset($myImages))
  3.    foreach$myNodes as $key => $obj )
  4.      echo $myNodes[$key]->Attributes['src'].'<br>';

Parameters:
string   $aTagName:  Tag name of nodes to be searched for

API Tags:
Access:  public


[ Top ]
getHtml  [line 217]

  string getHtml( )

Read the current HTML

Example:

  1.  echo $myParser->getHtml();


API Tags:
Access:  public


[ Top ]
parse  [line 193]

  void parse( string $aHtml  )

Parse an HTML string

Example:

  1.    $myParser->parse'<b>Hello</b>&nbsp;<i>world</i>!' );

Parameters:
string   $aHtml:  String containing HTML to be parsed

API Tags:
Access:  public


[ Top ]

Documentation generated on Mon, 29 Mar 2010 09:09:08 -0400 by phpDocumentor 1.4.3