User Contributed Notes 1 note

Basic: I use PHP5.4.9 from Ubuntu 13.04 repository. The aim of my code is to iterate HTML source (as a DomDocument) recursively and cleanup everything that is not valid to be used inside Epub files (i.e. and attribute align is not valid for paragraphs in Epubs).

FIRST: Today I tried removing attributes from a DOMElement using this simple code:<?phpfor ( $k=0; $k < $element->attributes->length; $k++) { if( /* some rule */ ){var_dump( $element->attributes->item($k)->nodeName);$element->removeAttributeNode( $element->attributes->item($k)); }}?>Unfortunately all attributes still existed when this loop was finished, even if these var_dumps told me that deleting them was tried.