public static function FeedsExXmlUtility::createXmlDocument in Feeds extensible parsers 7.2
Same name and namespace in other branches
- 7 src/Xml/Utility.php \FeedsExXmlUtility::createXmlDocument()
Creates an XML document.
Parameters
string $source: The string containing the XML.
int $options: (optional) Bitwise OR of the libxml option constants. Defaults to 0.
Return value
DOMDocument The newly created DOMDocument.
Throws
RuntimeException Thrown if there is a fatal error parsing the XML.
1 call to FeedsExXmlUtility::createXmlDocument()
- FeedsExXml::prepareDocument in src/
FeedsExXml.inc - Prepares the DOM document.
File
- src/
Xml/ Utility.php, line 47 - Contains FeedsExXmlUtility.
Class
- FeedsExXmlUtility
- Simple XML helpers.
Code
public static function createXmlDocument($source, $options = 0) {
$document = self::buildDomDocument();
$options = $options | LIBXML_NOENT | LIBXML_NONET | defined('LIBXML_COMPACT') ? LIBXML_COMPACT : 0;
if ((version_compare(PHP_VERSION, '5.3.2', '>=') || version_compare(PHP_VERSION, '5.2.12', '>=')) && version_compare(LIBXML_DOTTED_VERSION, '2.7.0', '>=')) {
$options = $options | LIBXML_PARSEHUGE;
}
if (!$document
->loadXML($source, $options)) {
throw new RuntimeException(t('There was an error parsing the XML document.'));
}
return $document;
}