Explanation: Answer option B is correct.
The children() function retrieves the child nodes of a specified XML node. It can be used to return an iterator containing a list of all subnodes of the current node. The syntax of the children() function is as follows:
- class SimpleXMLElement
- {
- string children(ns, is_prefix)
- }
where, ns is an XML namespace and is_prefix is a Boolean value that becomes TRUE if ns is regarded as a prefix.
Answer option A is incorrect. The asXML() function returns an XML string based on SimpleXML element. The syntax of the asXML function is as follows:
- class SimpleXMLElement
- {
- string asXML(file)
- }
where, when the file option is given, the asXML() function writes the string in a file instead of returning it.
Answer option D is incorrect. The getName() function is used to retrieve the name of an XML element from a SimpleXMLElement object. When it is successfully executed, it returns the name of the current XML element. The syntax of this function is as follows:
- class SimpleXMLElement
- {
- string getName()
- }
Answer option C is incorrect. The attributes() function is used to retrieve an XML elements attributes.
Reference: http://www.w3schools.com/php/php_ref_simplexml.asp