Question 1
Topic: Data Format & Types
Skill tested: Assesses safe parsing of untrusted XML with the XML extension and libxml error handling.
A logistics service accepts XML documents from external partners. The current implementation calls `simplexml_load_string()` directly and occasionally emits parser warnings into an API response; malformed payloads also make the request fail unclearly. The service must reject malformed XML, keep diagnostics out of the response, and report parsing failure through its own controlled error path. Which implementation is the most appropriate?
Internal libxml error handling lets the application capture parser diagnostics instead of emitting them as warnings, while the parser's return value can be checked for failure. The application can then produce a controlled response and clean up the error buffer and prior handling state. `LIBXML_NOERROR` merely suppresses reporting; it does not itself establish valid parsing or a clear failure path. `@` hides diagnostics but does not provide structured handling, and an empty valid document is not reliably distinguished that way. Recovery parsing can produce a modified document from malformed input, contrary to the requirement to reject it.