public function Crawler::addXmlContent in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/symfony/dom-crawler/Crawler.php \Symfony\Component\DomCrawler\Crawler::addXmlContent()
Adds an XML content to the list of nodes.
The libxml errors are disabled when the content is parsed.
If you want to get parsing errors, be sure to enable internal errors via libxml_use_internal_errors(true) and then, get the errors via libxml_get_errors(). Be sure to clear errors with libxml_clear_errors() afterward.
Parameters
string $content The XML content:
string $charset The charset:
1 call to Crawler::addXmlContent()
- Crawler::addContent in vendor/
symfony/ dom-crawler/ Crawler.php - Adds HTML/XML content.
File
- vendor/
symfony/ dom-crawler/ Crawler.php, line 233
Class
- Crawler
- Crawler eases navigation of a list of \DOMElement objects.
Namespace
Symfony\Component\DomCrawlerCode
public function addXmlContent($content, $charset = 'UTF-8') {
// remove the default namespace if it's the only namespace to make XPath expressions simpler
if (!preg_match('/xmlns:/', $content)) {
$content = str_replace('xmlns', 'ns', $content);
}
$internalErrors = libxml_use_internal_errors(true);
$disableEntities = libxml_disable_entity_loader(true);
$dom = new \DOMDocument('1.0', $charset);
$dom->validateOnParse = true;
if ('' !== trim($content)) {
@$dom
->loadXML($content, LIBXML_NONET);
}
libxml_use_internal_errors($internalErrors);
libxml_disable_entity_loader($disableEntities);
$this
->addDocument($dom);
}