删除xml中不必要的子元素(php)

І have the xml file and it has such structure:

    <section>
    <title>Title 1</title>
    Some text
    <section>
    <title>Title 2</title>
    Some text
    <section>
    <title>Title 3</title>
    Some text
    </section>
    </section>
    </section>

I need to remove all internall child elements section, except primary elements, without changing texts. Final result must be:

    <section>
    <title>Title 1</title>
    Some text
    <title>Title 2</title>
    Some text
    <title>Title 3</title>
    Some text
    </section>

I used SimpleXML and i accept such code:

foreach ($xml->body->children() as $section) {
$section = $section->asXML();

$section = strip_tags($section, '<title>');

}

But there is a problem, i dont know how to return the code in object xml after treatment of every element.

</div>