PHP | XMLReader XML() Function
The XMLReader::XML() function is an inbuilt function in PHP which is used to set the data containing the XML to parse. XML() function serves the same purpose as open function but the only difference is former accepts XML as string while later accepts it as a separate .xml file.
bool XMLReader::XML( string $source, string $encoding, int $options )
Parameters: This function accepts three parameters as mentioned above and described below:
- $source: It specifies the string containing the XML to be parsed.
- $encoding (Optional): It specifies the document encoding or NULL.
- $options (Optional): It specifies the optional bitmask.
Return Value: This function returns TRUE on success or FALSE on failure.
Exceptions: This function throws E_STRICT error when called statically.
Below examples illustrate the XMLReader::XML() function in PHP:
We are at div We are at p