Class HtmlNode

  • package PHPHtmlParser\Dom
CloneableInstantiableIterable
ExtendsPHPHtmlParser\Dom\InnerNode
PHPHtmlParser\Dom\ArrayNode
PHPHtmlParser\Dom\AbstractNode
ImplementsCountable
IteratorAggregate
Traversable
Methods
public __construct( $tag)
 
Sets up the tag of this node.

    public PHPHtmlParser\Dom\AbstractNode::__destruct()
     
    Attempts to clear out any object references.

    public PHPHtmlParser\Dom\AbstractNode::__get(string $key)
     
    Magic get method for attributes and certain methods.

    • return mixed
    public PHPHtmlParser\Dom\AbstractNode::__toString()
     
    Simply calls the outer text method.

    • return string
    public PHPHtmlParser\Dom\InnerNode::addChild(PHPHtmlParser\Dom\AbstractNode $child, int $before = -1) : bool
     
    Adds a child node to this node and returns the id of the child for this parent.

    • return bool
    • throws ChildNotFoundException
    • throws CircularException
    public PHPHtmlParser\Dom\AbstractNode::ancestorByTag(string $tag) : PHPHtmlParser\Dom\AbstractNode
     
    Function to locate a specific ancestor tag in the path to the root.

    public PHPHtmlParser\Dom\ArrayNode::count() : int
     
    Returns the count of the iterator array.

    • return int
    public PHPHtmlParser\Dom\InnerNode::countChildren() : int
     
    Counts children

    • return int
    public PHPHtmlParser\Dom\AbstractNode::delete()
     
    Removes this node and all its children from the DOM tree.

    • return void
    public PHPHtmlParser\Dom\AbstractNode::find(string $selector, ?int $nth = NULL, bool $depthFirst = false)
     
    Find elements by css selector

    • return mixed|\Collection|null
    • throws ChildNotFoundException
    public PHPHtmlParser\Dom\AbstractNode::findById(int $id)
     
    Find node by id

    • return bool|\AbstractNode
    • throws ChildNotFoundException
    • throws ParentNotFoundException
    public PHPHtmlParser\Dom\InnerNode::firstChild() : PHPHtmlParser\Dom\AbstractNode
    public PHPHtmlParser\Dom\AbstractNode::getAncestor(int $id)
     
    Attempts to get an ancestor node by the given id.

    • return null|\AbstractNode
    public PHPHtmlParser\Dom\AbstractNode::getAttribute(string $key) : string
     
    A wrapper method that simply calls the getAttribute method on the tag of this node.

    • return string|null
    public PHPHtmlParser\Dom\AbstractNode::getAttributes() : array
     
    A wrapper method that simply calls the getAttribute method on the tag of this node.

    • return array
    public PHPHtmlParser\Dom\InnerNode::getChild(int $id) : PHPHtmlParser\Dom\AbstractNode
     
    Returns the child by id.

    public PHPHtmlParser\Dom\InnerNode::getChildren() : array
     
    Returns a new array of child nodes

    • return array
    public PHPHtmlParser\Dom\ArrayNode::getIterator() : ArrayIterator
     
    Gets the iterator

    • return ArrayIterator
    public PHPHtmlParser\Dom\AbstractNode::getParent()
     
    Returns the parent of node.

    public PHPHtmlParser\Dom\AbstractNode::getTag() : PHPHtmlParser\Dom\Tag
     
    Gets the tag object of this node.

    public PHPHtmlParser\Dom\AbstractNode::hasAttribute(string $key) : bool
     
    A wrapper method that simply calls the hasAttribute method on the tag of this node.

    • return bool
    public PHPHtmlParser\Dom\InnerNode::hasChildren() : bool
     
    Checks if this node has children.

    • return bool
    public PHPHtmlParser\Dom\InnerNode::hasNextChild(int $id)
     
    Check if has next Child

    • return mixed
    • throws ChildNotFoundException
    public PHPHtmlParser\Dom\AbstractNode::hasNextSibling() : bool
     
    Checks if the current node has a next sibling.

    • return bool
    public PHPHtmlParser\Dom\AbstractNode::id() : int
     
    Returns the id of this object.

    • return int
    public innerHtml() : string
     
    Gets the inner html of this node.

    • return string
    • throws ChildNotFoundException
    • throws UnknownChildTypeException
    public PHPHtmlParser\Dom\InnerNode::insertAfter(PHPHtmlParser\Dom\AbstractNode $child, int $id) : bool
     
    Insert element before after with provided id

    • return bool
    • throws ChildNotFoundException
    • throws CircularException
    public PHPHtmlParser\Dom\InnerNode::insertBefore(PHPHtmlParser\Dom\AbstractNode $child, int $id) : bool
     
    Insert element before child with provided id

    • return bool
    • throws ChildNotFoundException
    • throws CircularException
    public PHPHtmlParser\Dom\AbstractNode::isAncestor(int $id) : bool
     
    Checks if the given node id is an ancestor of the current node.

    • return bool
    public PHPHtmlParser\Dom\InnerNode::isChild(int $id) : bool
     
    Checks if the given node id is a child of the current node.

    • return bool
    public PHPHtmlParser\Dom\InnerNode::isDescendant(int $id) : bool
     
    Checks if the given node id is a descendant of the current node.

    • return bool
    public PHPHtmlParser\Dom\AbstractNode::isTextNode() : bool
     
    Check is node type textNode

    • return bool
    public PHPHtmlParser\Dom\InnerNode::lastChild() : PHPHtmlParser\Dom\AbstractNode
    public PHPHtmlParser\Dom\InnerNode::nextChild(int $id) : PHPHtmlParser\Dom\AbstractNode
    public PHPHtmlParser\Dom\AbstractNode::nextSibling() : PHPHtmlParser\Dom\AbstractNode
     
    Attempts to get the next sibling.

    public outerHtml() : string
     
    Gets the html of this node, including it's own tag.

    • return string
    • throws ChildNotFoundException
    • throws UnknownChildTypeException
    public PHPHtmlParser\Dom\InnerNode::previousChild(int $id) : PHPHtmlParser\Dom\AbstractNode
    public PHPHtmlParser\Dom\AbstractNode::previousSibling() : PHPHtmlParser\Dom\AbstractNode
     
    Attempts to get the previous sibling.

    public PHPHtmlParser\Dom\InnerNode::propagateEncoding(stringEncode\Encode $encode) : void
     
    Sets the encoding class to this node and propagates it to all its children.

    • return void
    public PHPHtmlParser\Dom\AbstractNode::removeAllAttributes() : void
     
    A wrapper method that simply calls the removeAllAttributes method on the tag of this node.

    • return void
    public PHPHtmlParser\Dom\AbstractNode::removeAttribute(string $key) : void
     
    A wrapper method that simply calls the removeAttribute method on the tag of this node.

    • return void
    public PHPHtmlParser\Dom\InnerNode::removeChild(int $id) : PHPHtmlParser\Dom\InnerNode
     
    Removes the child by id.

    public PHPHtmlParser\Dom\InnerNode::replaceChild(int $childId, PHPHtmlParser\Dom\AbstractNode $newChild) : void
     
    Removes the child with id $childId and replace it with the new child $newChild.

    • return void
    public static PHPHtmlParser\Dom\AbstractNode::resetCount()
     
    Reset node counter

    • return void
    public PHPHtmlParser\Dom\AbstractNode::setAttribute(string $key, $value) : PHPHtmlParser\Dom\AbstractNode
     
    A wrapper method that simply calls the setAttribute method on the tag of this node.

    public setHtmlSpecialCharsDecode( $htmlSpecialCharsDecode = false) : void
     


    • return void
    public PHPHtmlParser\Dom\InnerNode::setParent(PHPHtmlParser\Dom\InnerNode $parent) : PHPHtmlParser\Dom\AbstractNode
     
    Sets the parent node.

    public text(bool $lookInChildren = false) : string
     
    Gets the text of this node (if there is any text). Or get all the text in this node, including children.

    • return string
    Properties
    protected PHPHtmlParser\Dom\AbstractNode::$attr
     
    Contains a list of attributes on this tag.

    • var array
    protected PHPHtmlParser\Dom\InnerNode::$children
     
    An array of all the children.

    • var array
    protected PHPHtmlParser\Dom\AbstractNode::$encode
     
    The encoding class used to encode strings.

    • var mixed
    protected PHPHtmlParser\Dom\AbstractNode::$htmlSpecialCharsDecode
     


    • var bool
    protected PHPHtmlParser\Dom\AbstractNode::$id
     
    The unique id of the class. Given by PHP.

    • var int
    protected $innerHtml
     
    Remembers what the innerHtml was if it was scanned previously.

    • var ?string
    protected $outerHtml
     
    Remembers what the outerHtml was if it was scanned previously.

    • var ?string
    protected PHPHtmlParser\Dom\AbstractNode::$parent
     
    Contains the parent Node.

    • var ?\InnerNode
    protected PHPHtmlParser\Dom\AbstractNode::$tag
     
    Contains the tag name/type

    • var ?\Tag
    protected $text
     
    Remembers what the text was if it was scanned previously.

    • var ?string
    protected $textWithChildren
     
    Remembers what the text was when we looked into all our children nodes.

    • var ?string
    Methods
    protected clear() : void
     
    Call this when something in the node tree has changed. Like a child has been added or a parent has been changed.

    protected getIteratorArray() : array
     
    Returns all children of this html node.

    • return array
    Methods
    public static PHPHtmlParser\Dom\AbstractNode::resetCount()
     
    Reset node counter

    • return void
    © 2020 Bruce Wells
    Search Namespaces \ Classes
    ConfigurationNumbers (0-9.) only