nerdexam
Zend

200-710 · Question #173

What SimpleXML function is used to parse a file?

The correct answer is A. simplexml_load_file(). simplexml_load_file() is correct because it accepts a file path (or URL) as its argument and parses the XML file directly into a SimpleXMLElement object, making it the dedicated function for file-based XML parsing in PHP. Why the distractors are wrong: B…

XML & Web Services

Question

What SimpleXML function is used to parse a file?

Options

  • Asimplexml_load_file()
  • Bsimplexml_load_string()
  • Cload()
  • DloadFile()
  • EloadXML()
  • FNone of the above.

How the community answered

(28 responses)
  • A
    82% (23)
  • C
    11% (3)
  • E
    4% (1)
  • F
    4% (1)

Explanation

simplexml_load_file() is correct because it accepts a file path (or URL) as its argument and parses the XML file directly into a SimpleXMLElement object, making it the dedicated function for file-based XML parsing in PHP.

Why the distractors are wrong:

  • B. simplexml_load_string() - this is a real PHP function, but it parses an XML string already in memory, not a file on disk.
  • C. load() - not a standalone SimpleXML function; this is a method on PHP's DOMDocument class, a different XML API.
  • D. loadFile() - doesn't exist in PHP's SimpleXML or standard XML libraries.
  • E. loadXML() - also a DOMDocument method (parses an XML string), not a SimpleXML function.

Memory tip: Think of it as a two-function family - simplexml_load_**file**() for files, simplexml_load_**string**() for strings. The suffix tells you what you're feeding it. If it doesn't start with simplexml_, it's not in the SimpleXML extension.

Topics

#SimpleXML#simplexml_load_file#XML parsing

Community Discussion

No community discussion yet for this question.

Full 200-710 Practice