Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add function detect if any current context node, so that xpath() work… #37

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/Rct567/DomQuery/DomQueryNodes.php
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,24 @@ public function xpathQuery(string $expression, \DOMNode $context_node=null)
return false;
}

/**
* Shows if the context node can be used in xpath queries.
*
* If it's not set, it can be set then used in the following:
* @code
* if (!$dom->isContextNodeSet()) {
* $dom = $dom->find(':root');
* }
* $dom->xpath("/child::div[contains(concat(' ', normalize-space(@class), ' '), ' myclass ')]");
*
* @endcode
*
* @return bool
*/
public function isContextNodeSet() {
return (isset($this->root_instance) || isset($this->xpath_query));
}

/**
* Create dom xpath instance
*
Expand Down