tags:

views:

40

answers:

1

How can I move an xml element elsewhere in a document? So I have this:

<outer>
    <foo>
        <child name="a"/>
        <child name="b"/>
        <child name="c"/>
    </foo>
    <bar />
</outer>

and want to end up with:

<outer>
    <foo />
    <bar>
        <child name="a"/>
        <child name="b"/>
        <child name="c"/>
    </bar>
</outer>

Using PHP's simpleXML.

Is there a function I'm missing (appendChild-like)?

A: 

You could make a recusrive function that clones the attributes and children. There is no other way to move the children with SimpleXML

Nin