awsCommonXML

Back
Class structure
  • abstract awsCommonXML
    • Properties
      • DOMNode current
      • DOMDocument doc
      • DOMNodeList results
    • Methods
      • awsCommonXML_Child after( string $htmlString)
      • awsCommonXML_Child append( string $htmlString)
      • awsCommonXML_Child attr( string $name, string $value)
      • awsCommonXML_Child before( string $htmlString)
      • string content()
      • void copyElement( DOMNode $domElement, DOMNode $targetNode, string $newNodeName, bool $skipChilds = false, bool $skipAttributes = false)
      • awsCommonXML_Child csse( string $cssQuery, DOMNode $context)
      • Run a css evaluate over the context
      • awsCommonXML_Child cssq( string $cssQuery, DOMNode $context)
      • Run a css query over the context
      • string documentContent()
      • awsCommonXML_Child e( string $xpathQuery, DOMNode $context)
      • Run a xpath evaluate over the context
      • awsCommonXML_Child each( string $callbackFunction, mixed param1, mixed param2,..., mixed paramn)
      • Executes a function for each DOMNode of the last query; Function can be either an already defined one or an anonymous (lambda style) function (See create_function);
        Default parameter of the function, when called, is $el, the current DOMNode in DOMNodeList (results property or last query result);
        Since AWS XMS 1.0 beta 10 you can specify as many parameters you need as these will be passed to the function when executed;

        Example:
        function someFunction(&el,$name,$value)
        {$el->setAttribute($name,$value);}

        function otherFunction(&el)
        {$el->setAttribute("anAttribute","value");}

        $an_awsCommonXML_ChildInstance->q("xpathSelector")
        ->each("someFunction","newAttribute","value")
        ->cssq("cssSelector")->each("otherFunction");

        echo $domNodeListItem->nodeName." = ".$domNodeListItem->nodeValue;

        Or:

        $parser = new awsCommonXML_Child($GLOBALS["HTMLPARSER"]->cssq("#menu")->results->item(0));
        $liParser = new awsCommonXML_Child($parser->q("descendant::li")->results->item(0));

        $liParser->q("a")->each(create_function('&$el,$name,$value','$el->setAttribute($name,$value);'),"ATTRNAME","ATTRVAL");

        echo $liParser->results->item(0)->getAttribute("ATTRNAME");
      • DOMNode filter()
      • DOMNode first()
      • Return first DOMNode of the last query
      • DOMNode getRootElement()
      • DOMNode iterate()
      • Iterates through the results of the last query; Current node is thecurrent property of the awsCommonXML_Child object;
        To be used with while
      • DOMNode last()
      • Return last DOMNode of the last query
      • awsCommonXML_Child prepend( string $htmlString)
      • awsCommonXML_Child q( string $xpathQuery, DOMNode $context)
      • Run a xpath query over the context
      • awsCommonXML_Child removeAttr( string $name)
      • awsCommonXML_Child removeChilds()
      • awsCommonXML_Child replace( string $htmlString)
      • awsCommonXML_Child replaceContent( string $htmlString)
      • string resultsAsSource()
      • Retrieve the source of all DOMNodes of the last query;
      • DOMDocumentFragment resultsAsDocumentFragment()
      • Retrieve all DOMNodes of the last query as DOMDocumentFragment;
      • mixed text([ string $newText])
      • Parameter:
        string $newText - optional

        - When called like $an_awsCommonXML_Child->text() will return the text content of all nodes of the last query;

        - When called like $an_awsCommonXML_Child->text("some text") will set text content of all nodes of the last query;
      • awsCommonXML_Child to($variable)
      • Assigns the results (as DOMNodeList) of the last query to the variable passed as parameter
        $someVar = "";
        $an_awsCommonXML_Child_basedClass->q("xpathSelector")->to($someVar);
        foreach($someVar as $domNodeListItem)
        echo $domNodeListItem->nodeName." = ".$domNodeListItem->nodeValue;