@@ -135,6 +135,7 @@ public function __get($name)
135135 */
136136 public function load ($ str , $ options = [])
137137 {
138+ AbstractNode::resetCount ();
138139 // check if it's a file
139140 if (strpos ($ str , "\n" ) === false && is_file ($ str )) {
140141 return $ this ->loadFromFile ($ str , $ options );
@@ -234,6 +235,20 @@ public function find($selector, $nth = null)
234235 return $ this ->root ->find ($ selector , $ nth );
235236 }
236237
238+ /**
239+ * Find element by Id on the root node
240+ *
241+ * @param int $id Element Id
242+ * @return mixed
243+ *
244+ */
245+ public function findById ($ id )
246+ {
247+ $ this ->isLoaded ();
248+
249+ return $ this ->root ->findById ($ id );
250+ }
251+
237252 /**
238253 * Adds the tag (or tags in an array) to the list of tags that will always
239254 * be self closing.
@@ -353,6 +368,42 @@ public function lastChild()
353368 return $ this ->root ->lastChild ();
354369 }
355370
371+ /**
372+ * Simple wrapper function that returns count of child elements
373+ *
374+ * @return int
375+ */
376+ public function countChildren ()
377+ {
378+ $ this ->isLoaded ();
379+
380+ return $ this ->root ->countChildren ();
381+ }
382+
383+ /**
384+ * Get array of children
385+ *
386+ * @return array
387+ */
388+ public function getChildren ()
389+ {
390+ $ this ->isLoaded ();
391+
392+ return $ this ->root ->getChildren ();
393+ }
394+
395+ /**
396+ * Check if node have children nodes
397+ *
398+ * @return bool
399+ */
400+ public function hasChildren ()
401+ {
402+ $ this ->isLoaded ();
403+
404+ return $ this ->root ->hasChildren ();
405+ }
406+
356407 /**
357408 * Simple wrapper function that returns an element by the
358409 * id.
@@ -453,7 +504,9 @@ protected function clean($str)
453504 }
454505
455506 // strip out server side scripts
456- $ str = mb_eregi_replace ("(<\?)(.*?)(\?>) " , '' , $ str );
507+ if ($ this ->options ->get ('serverSideScriptis ' ) == true ){
508+ $ str = mb_eregi_replace ("(<\?)(.*?)(\?>) " , '' , $ str );
509+ }
457510
458511 // strip smarty scripts
459512 $ str = mb_eregi_replace ("(\{\w)(.*?)(\}) " , '' , $ str );
0 commit comments