function index($count_all = true)
{
if (!$this->parent) {
return -1;
} elseif ($count_all) {
return $this->parent->findChild($this);
} else {
$index = -1;
//foreach($this->parent->children as &$c) {
// if (!$c->isTextOrComment()) {
// ++$index;
// }
// if ($c === $this) {
// return $index;
// }
//}
foreach (array_keys($this->parent->children) as $k) {
if (!$this->parent->children[$k]->isTextOrComment()) {
++$index;
}
if ($this->parent->children[$k] === $this) {
return $index;
}
}
return -1;
}
}