Writing Changes Back to a Zend Dom Query Object
问题 I want to loop through images in an HTML document and set the width/height if they don't exist. Here's a minimal piece of working code: $content = '<img src="example.gif" />'; $dom = new Zend_Dom_Query($content); $imgs = $dom->query('img'); foreach ($imgs as $img) { $width = (int) $img->getAttribute('width'); $height = (int) $img->getAttribute('height'); if ((0 == $width) && (0 == $height)) { $img->setAttribute('width', 100)); $img->setAttribute('height', 100); } } $content = $dom-