protected static function getNodes(DOMDocument $dom, $type)
	{
		$nodes  = [];
		$prefix = ($type === 'attribute') ? '@' : '';
		$xpath  = new DOMXPath($dom);

		// Get natural nodes
		foreach ($xpath->query('//' . $prefix . '*') as $node)
		{
			$nodes[] = [$node, $node->nodeName];
		}

		// Get XSL-generated nodes
		foreach ($xpath->query('//xsl:' . $type) as $node)
		{
			$nodes[] = [$node, $node->getAttribute('name')];
		}

		// Get xsl:copy-of nodes
		foreach ($xpath->query('//xsl:copy-of') as $node)
		{
			if (preg_match('/^' . $prefix . '(\\w+)$/', $node->getAttribute('select'), $m))
			{
				$nodes[] = [$node, $m[1]];
			}
		}

		return $nodes;
	}
protected static function getNodes(DOMDocument $dom, $type)
	{
		$nodes  = [];
		$prefix = ($type === 'attribute') ? '@' : '';
		$xpath  = new DOMXPath($dom);

		// Get natural nodes
		foreach ($xpath->query('//' . $prefix . '*') as $node)
		{
			$nodes[] = [$node, $node->nodeName];
		}

		// Get XSL-generated nodes
		foreach ($xpath->query('//xsl:' . $type) as $node)
		{
			$nodes[] = [$node, $node->getAttribute('name')];
		}

		// Get xsl:copy-of nodes
		foreach ($xpath->query('//xsl:copy-of') as $node)
		{
			if (preg_match('/^' . $prefix . '(\\w+)$/', $node->getAttribute('select'), $m))
			{
				$nodes[] = [$node, $m[1]];
			}
		}

		return $nodes;
	}
protected static function getNodes ( DOMDocument $ dom , $ type ) { $ nodes = [ ] ; $ prefix = ( $ type === 'attribute' ) ? '@' : '' ; $ xpath = new DOMXPath ( $ dom ) ; // Get natural nodes foreach ( $ xpath -> query ( '//' . $ prefix . '*' ) as $ node ) { $ nodes [ ] = [ $ node , $ node -> nodeName ] ; } // Get XSL-generated nodes foreach ( $ xpath -> query ( '//xsl:' . $ type ) as $ node ) { $ nodes [ ] = [ $ node , $ node -> getAttribute ( 'name' ) ] ; } // Get xsl:copy-of nodes foreach ( $ xpath -> query ( '//xsl:copy-of' ) as $ node ) { if ( preg_match ( '/^' . $ prefix . '(\\w+)$/' , $ node -> getAttribute ( 'select' ) , $ m ) ) { $ nodes [ ] = [ $ node , $ m [ 1 ] ] ; } } return $ nodes ; }
Return all nodes of given type

@param  DOMDocument $dom  Owner document
@param  string      $type Node type ('element' or 'attribute')
@return DOMNode[]         List of DOMNode instances
Return all nodes of given type