awsHTML::_constructor

Back awsHTML __construct( mixed $from)

Where $from can be:
- string: build an awsHTML object from the given sting;
- DOMDocument: build an awsHTML using this DOMDocument; default context will be $from DOMDocument;
- DOMNode: build an awsHTML using this DOMNode->ownerDocument; default context will be $from DOMNode;
- DOMElement: build an awsHTML using this DOMNode->ownerDocument; default context will be $from DOMElement;
- awsHTML: build an awsHTML using doc property of $from object; default context will be doc DOMDocument;

Why setting up a default context:
- DOMXpath::query and DOMXpath::evaluate have two parameters, selector and context;
When setting up a default context, each time when a query is made, context parameter of DOMXpath::query or DOMXpath::evaluate will be default one, if no other specified when calling awsHTML::q or awsHTML::e or awsHTML::cssq or awsHTML::csse;

Example:
<html>
<head>

</head>
<body>
<div>

<input type="radio" name="newsletter" value="Hot Fuzz" />
<span>name?</span>

</div>
<div>
<input type="radio" name="newsletters" value="Cold Fusion" />

<span>other name?</span>
</div>
<div>
<input type="radio" name="accept" value="Evil Plans" />
<span>some other name?</span>
</div>

</body>
</html>
//$htmlString is html code above
$parser = new awsHTML($htmlString);
$parser->q("//div[0]")->to($firstDivNodeList);

$firstDiv_asDOMNode = $firstDivNodeList->item(0);

$newParser = new awsHTML($firstDiv_asDOMNode);
echo $newParser->cssq("*[@type='radio']")->results->item(0)->getAttribute("value");
//will output:
//Hot Fuzz

echo $newParser->q("//span")->results->item(0)->textContent;
//will output:
//name?