I am using a parser to change certain span elements to corresponding heading elements. I have the following code:
$headingReplace[1]['h']     = 'h1';
$headingReplace[1]['string']    = '/html/body//span[@class="heading1"]';            $headingReplace[1]['h']     = 'h1';
    foreach($headingReplace as $heading){
        foreach ($xp->query($heading['string']) as $span) {
            $h1 = $dom->createElement($heading['h']);
            $h1->setAttribute('class', $span->getAttribute('class'));
            while($span->childNodes->length > 0) {
                $h1->appendChild($span->childNodes->item(0));
            }
            $span->parentNode->replaceChild($h1, $span);
        }   
    }
    return $dom->saveHtml();
It all works fine, but the spans are also wrapped in p tags, eg.
<p><span class="heading1">Blah Blah</span></p>
Which I want removed. I guess after the 'appendChild' line, I want a line to 'removeParent', but I can't get it to work. Any ideas?
Thanks in advance.
 
     
     
    
after every heading, how would I do it...? Thanks – Inigo Dec 30 '11 at 22:20