Michael
Michael

Reputation: 4876

Delete a SimpleXMLElement?

I found (here) an answer regarding the way to delete a node of a SimpleXMLElement object.

The problem is I can not really understand how is that happening.

I mean, that $image var is a ref, right? So, what and where it is that $image[0][0]?

Upvotes: 3

Views: 148

Answers (2)

Francis Avila
Francis Avila

Reputation: 31621

SimpleXMLElement presents an array-like interface on its child nodes via magic methods. This behavior is because of custom __unset behavior that causes the SimpleXMLElement to act as though a "member" (child element) of its "array" (set of child elements) has been removed.

Upvotes: 1

Jimzie
Jimzie

Reputation: 737

If you put a print_r($image) right after the $image = $galleries->xpath(...

you'll see:

Array
(
    [0] => SimpleXMLElement Object
        (
            [@attributes] => Array
                (
                    [name] => Hansio
                )

        )

)

Upvotes: 0

Related Questions