1--TEST-- 2Test reading Element::$innerHTML on XML documents 3--EXTENSIONS-- 4dom 5--FILE-- 6<?php 7 8$dom = DOM\XMLDocument::createEmpty(); 9 10function createContainer() { 11 global $dom; 12 $element = $dom->createElement("container"); 13 return $element; 14} 15 16$container = createContainer(); 17$container->append("Hello, world!"); 18var_dump($container->innerHTML); 19 20$container = createContainer(); 21$container->append($dom->createComment("This is -a- comment")); 22var_dump($container->innerHTML); 23 24$container = createContainer(); 25// Note: intentionally typo'd to check whether the string matching against "xml" happens correctly 26// i.e. no bugs with prefix-matching only. 27$container->append($dom->createProcessingInstruction("xmll", "")); 28var_dump($container->innerHTML); 29 30$container = createContainer(); 31$container->append($dom->createProcessingInstruction("almostmalformed", ">?")); 32var_dump($container->innerHTML); 33 34$container = createContainer(); 35$element = $container->appendChild(createContainer()); 36$element->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns', 'http://example.com/'); 37var_dump($container->innerHTML); 38 39$container = createContainer(); 40$element = $container->appendChild(createContainer()); 41$element->setAttributeNS('urn:a', 'name', ''); 42$element->setAttributeNS('urn:b', 'name', ''); 43var_dump($container->innerHTML); 44 45$dom = DOM\XMLDocument::createFromFile(__DIR__ . '/../../book.xml'); 46var_dump($dom->documentElement->innerHTML); 47 48?> 49--EXPECT-- 50string(13) "Hello, world!" 51string(26) "<!--This is -a- comment-->" 52string(9) "<?xmll ?>" 53string(22) "<?almostmalformed >??>" 54string(12) "<container/>" 55string(72) "<container xmlns:ns1="urn:a" ns1:name="" xmlns:ns2="urn:b" ns2:name=""/>" 56string(167) " 57 <book> 58 <title>The Grapes of Wrath</title> 59 <author>John Steinbeck</author> 60 </book> 61 <book> 62 <title>The Pearl</title> 63 <author>John Steinbeck</author> 64 </book> 65" 66