FluentDOM\Nodes::load PHP Method

load() public method

Load a $source. The type of the source depends on the loaders. If no explicit loaders are set it will use a set of default loaders for xml/html and json.
public load ( mixed $source, string $contentType = 'text/xml', array | Traversable | Options $options = [] )
$source mixed
$contentType string optional, default value 'text/xml'
$options array | Traversable | FluentDOM\Loader\Options
    public function load($source, $contentType = 'text/xml', $options = [])
    {
        $loaded = $this->prepareSource($source, $contentType, $options);
        if ($loaded instanceof Loader\Result || $loaded instanceof \DOMDocument) {
            if ($loaded instanceof Loader\Result) {
                $this->_document = $loaded->getDocument();
                $this->setContentType($loaded->getContentType());
                if ($selection = $loaded->getSelection()) {
                    $this->push($selection);
                }
            } else {
                $this->_document = $loaded;
                $this->setContentType($contentType);
            }
            $this->_xpath = NULL;
            $this->applyNamespaces();
            return $this;
        }
        throw new Exceptions\InvalidSource($source, $contentType);
    }