Skip to content

Handle arrays returned by ->xpath() #1

@IMSoP

Description

@IMSoP

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"?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions