php - How to check DOMElement setIdAttribute() is set? -
assuming have following code.
$newdom = new domdocument(); $elem = new domelement('div'); $text = new domtext('testing'); $elem = $newdom->importnode($elem,true); $newdom->appendchild($elem); $text = $newdom->importnode($text,true); $elem->appendchild($text); $elem->setattribute('id','foo'); $elem->setidattribute('id',true); $elem->setidattribute('id',true); //set twice cause c14n() fail echo $newdom->getelementbyid('foo')->c14n(); if setidattribute() called twice, c14n() not work. now, problem is, if have domelement input function, in order make domelement can getelementbyid(), need setidattribute(). since cannot set twice, how check whether set or not?
after hours of trying, after post, found solution. there isid() domattr allows check attribute.
Comments
Post a Comment