simplexml_debug icon indicating copy to clipboard operation
simplexml_debug copied to clipboard

Handle arrays returned by ->xpath()

Open IMSoP opened this issue 12 years ago • 0 comments

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 or var_export?
  • Should arrays be handled recursively, or as a single loop, with nested arrays treated as "unhandled"?

IMSoP avatar Sep 05 '12 21:09 IMSoP