Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Static Public Member Functions
Xpath Class Reference

Static Public Member Functions

static getElementsCountForXpath ($xpath, $html)
 

Detailed Description

Definition at line 8 of file Xpath.php.

Member Function Documentation

◆ getElementsCountForXpath()

static getElementsCountForXpath (   $xpath,
  $html 
)
static

Get elements count for XPath

Parameters
string$xpath
string$html
Returns
int

Definition at line 17 of file Xpath.php.

18  {
19  $domDocument = new \DOMDocument('1.0', 'UTF-8');
20  libxml_use_internal_errors(true);
21  $domDocument->loadHTML($html);
22  libxml_use_internal_errors(false);
23  $domXpath = new \DOMXPath($domDocument);
24  $nodes = $domXpath->query($xpath);
25  return $nodes->length;
26  }

The documentation for this class was generated from the following file: