Index: tests/Zend/Dom/QueryTest.php =================================================================== --- tests/Zend/Dom/QueryTest.php (revision 24814) +++ tests/Zend/Dom/QueryTest.php (working copy) @@ -325,6 +325,29 @@ $this->query->setDocument($xhtmlWithXmlDecl, 'utf-8'); $this->assertEquals(1, $this->query->query('//p')->count()); } + + /** + * @group ZF-12106 + */ + public function testXhtmlDocumentWithXmlAndDoctypeDeclaration() + { + $xhtmlWithXmlDecl = << + + + + Virtual Library + + +

Moved to example.org.

+ + +EOB; + $this->query->setDocument($xhtmlWithXmlDecl, 'utf-8'); + $this->assertEquals(1, $this->query->query('//p')->count()); + } } // Call Zend_Dom_QueryTest::main() if this source file is executed directly. Index: library/Zend/Dom/Query.php =================================================================== --- library/Zend/Dom/Query.php (revision 24814) +++ library/Zend/Dom/Query.php (working copy) @@ -124,7 +124,7 @@ } // breaking XML declaration to make syntax highlighting work if ('<' . '?xml' == substr(trim($document), 0, 5)) { - if (preg_match('/\?'.'>\s+]*xmlns="([^"]+)"[^>]*>/i', $document, $matches)) { + if (preg_match('/]*xmlns="([^"]+)"[^>]*>/i', $document, $matches)) { $this->_xpathNamespaces[] = $matches[1]; return $this->setDocumentXhtml($document, $encoding); }