XBRL-Package.php
public function getInstanceDocument( $asSimpleXML = true )
	{
		if ( ! $this->schemaFile || ! $this->schemaNamespace )
		{
			echo "The saveTaxonomy function must be called before using this function";
			return false;
		}

		if ( $this->instanceDocument )
		{
			$xml = $asSimpleXML
				? $this->getFileAsXML( $this->instanceDocument )
				: $this->getFile( $this->instanceDocument );
			return $xml;
		}

		$xml = null;
		$this->traverseContents( function( $path, $name, $type ) use( &$xml )
		{
			if ( $type == PATHINFO_DIRNAME ) return true;
			$extension = pathinfo( $name, PATHINFO_EXTENSION );
			if ( ! in_array( $extension, array( 'xml', 'xbrl' ) ) ) return true;

			$path = $path ? "$path$name" : $name;
			$xml = $this->getFileAsXML( $path );
			if ( ! $xml instanceof SimpleXMLElement ) return true;

			if ( $xml->getName() != "xbrl" )
			{
				$xml = null;
				return true;
			}

			$this->instanceDocument = $path;
			return false;
		} );

		if ( ! $xml instanceof SimpleXMLElement ) return null;

		return $asSimpleXML
			? $xml
			: $this->getFile( $this->instanceDocument );
	}
public function getInstanceDocument( $asSimpleXML = true )
	{
		if ( ! $this->schemaFile || ! $this->schemaNamespace )
		{
			echo "The saveTaxonomy function must be called before using this function";
			return false;
		}

		if ( $this->instanceDocument )
		{
			$xml = $asSimpleXML
				? $this->getFileAsXML( $this->instanceDocument )
				: $this->getFile( $this->instanceDocument );
			return $xml;
		}

		$xml = null;
		$this->traverseContents( function( $path, $name, $type ) use( &$xml )
		{
			if ( $type == PATHINFO_DIRNAME ) return true;
			$extension = pathinfo( $name, PATHINFO_EXTENSION );
			if ( ! in_array( $extension, array( 'xml', 'xbrl' ) ) ) return true;

			$path = $path ? "$path$name" : $name;
			$xml = $this->getFileAsXML( $path );
			if ( ! $xml instanceof SimpleXMLElement ) return true;

			if ( $xml->getName() != "xbrl" )
			{
				$xml = null;
				return true;
			}

			$this->instanceDocument = $path;
			return false;
		} );

		if ( ! $xml instanceof SimpleXMLElement ) return null;

		return $asSimpleXML
			? $xml
			: $this->getFile( $this->instanceDocument );
	}
public function getInstanceDocument ( $ asSimpleXML = true ) { if ( ! $ this -> schemaFile || ! $ this -> schemaNamespace ) { echo "The saveTaxonomy function must be called before using this function" ; return false ; } if ( $ this -> instanceDocument ) { $ xml = $ asSimpleXML ? $ this -> getFileAsXML ( $ this -> instanceDocument ) : $ this -> getFile ( $ this -> instanceDocument ) ; return $ xml ; } $ xml = null ; $ this -> traverseContents ( function ( $ path , $ name , $ type ) use ( & $ xml ) { if ( $ type == PATHINFO_DIRNAME ) return true ; $ extension = pathinfo ( $ name , PATHINFO_EXTENSION ) ; if ( ! in_array ( $ extension , array ( 'xml' , 'xbrl' ) ) ) return true ; $ path = $ path ? "$path$name" : $ name ; $ xml = $ this -> getFileAsXML ( $ path ) ; if ( ! $ xml instanceof SimpleXMLElement ) return true ; if ( $ xml -> getName ( ) != "xbrl" ) { $ xml = null ; return true ; } $ this -> instanceDocument = $ path ; return false ; } ) ; if ( ! $ xml instanceof SimpleXMLElement ) return null ; return $ asSimpleXML ? $ xml : $ this -> getFile ( $ this -> instanceDocument ) ; }
Get the instance document xml
@param bool $asSimpleXML
@return SimpleXMLElement|string
Get the instance document xml