simplexml_debug
simplexml_debug copied to clipboard
Handle arrays returned by ->xpath()
The xpath()
method doesn't return a SimpleXMLElement
, but an actual array of objects. simplexml_dump()
will currently return an error if you try to pass it this array.
Keeping this limitation keeps the function simple as it always gets a single SimpleXMLElement
object, and doesn't need to do any recursion or similar. However, it means that not every SimpleXML operation can be trivially debugged with this function.
Would need to consider how to handle completely unrelated data types, including arrays with some SimpleXMLElement
values as well as some others:
- Fatal error on unhandled type?
- Warn and continue (e.g. in an array loop)?
- Fall back to another debug function, such as
print_r
orvar_export
? - Should arrays be handled recursively, or as a single loop, with nested arrays treated as "unhandled"?