19 $this->nodeName =
'#document';
21 $this->ownerDocument = $this;
32 $this->parser->parse($source, $this);
39 public function saveHTML(
Node $node =
null)
45 if(self::$isNodeListAsArray)
51 $result .= $child->getOuterHTML();
62 $result .= $child->getOuterHTML();
71 return $node->getOuterHTML();
80 if(!$this->queryEngine)
94 $this->queryEngine = $engine;
119 public function adoptNode(
Node $source)
131 foreach($attrList as $attr)
134 $attr->setOwnerDocument($this);
143 $child->setOwnerDocument($this);
154 static $classByTag = array();
156 $tagName = mb_strtoupper($tagName);
157 $elementClass =
"Bitrix\\Main\\Web\\DOM\\Element\\" . $tagName;
159 if(!isset($classByTag[$tagName]))
161 if(class_exists($elementClass))
163 $classByTag[$tagName] = $elementClass;
167 $classByTag[$tagName] =
false;
171 if($classByTag[$tagName])
173 $elementClass = $classByTag[$tagName];
174 $node =
new $elementClass($tagName);
181 $node->setOwnerDocument($this);
192 $node =
new Attr($name, $value);
193 $node->setOwnerDocument($this);
204 $node->setOwnerDocument($this);
214 $node =
new Text($text);
215 $node->setOwnerDocument($this);
233 return (!empty($resultList)) ? current($resultList) :
null;
242 return (!empty($resultList)) ? current($resultList) :
null;
263 $attrName = mb_strtolower($attrName);
270 'value' => $attrValue,
294 $tagName = mb_strtoupper($tagName);
337 public function getDocumentElement()
342 if($child->getNodeName() ===
'HTML')
355 public function getHead()
357 if(!$this->getDocumentElement())
365 if($child->getNodeName() ===
'HEAD')
380 if(!$this->getDocumentElement())
388 if($child->getNodeName() ===
'BODY')
createAttribute($name, $value)
getElementByClassName($className)
getElementsByClassName($className, $limit=0)
getElementsByTagName($tagName)
setQueryEngine(QueryEngine $engine)
getElementsByAttr($attrName, $attrValue=null, $limit=0)
setParser(Parser $parser)
setOwnerDocument(Document $owner)
static $isNodeListAsArray
const FILTER_OPERATION_EQUAL
const FILTER_ATTR_CLASS_NAME
static getQuerySelectorEngine()