1--TEST-- 2DOMEntity fields 3--EXTENSIONS-- 4dom 5--FILE-- 6<?php 7$xmlString = <<<XML 8<?xml version="1.0"?> 9<!DOCTYPE test [ 10 <!ENTITY sampleInternalEntity "This is a sample entity value."> 11 <!ENTITY sampleExternalSystemWithNotationName SYSTEM "external.stuff" NDATA stuff> 12 <!ENTITY sampleExternalSystemWithoutNotationName SYSTEM "external.stuff" NDATA > 13 <!ENTITY sampleExternalPublicWithNotationName1 PUBLIC "public id" "external.stuff" NDATA stuff> 14 <!ENTITY sampleExternalPublicWithNotationName2 PUBLIC "" "external.stuff" NDATA stuff> 15 <!ENTITY sampleExternalPublicWithoutNotationName1 PUBLIC "public id" "external.stuff" NDATA > 16 <!ENTITY sampleExternalPublicWithoutNotationName2 PUBLIC "" "external.stuff" NDATA > 17]> 18<root/> 19XML; 20 21$dom = new DOMDocument(); 22$dom->loadXML($xmlString); 23 24// Sort them, the iteration order isn't defined 25$entities = iterator_to_array($dom->doctype->entities); 26ksort($entities); 27 28foreach ($entities as $entity) { 29 echo "Entity name: {$entity->nodeName}\n"; 30 echo "publicId: "; 31 var_dump($entity->publicId); 32 echo "systemId: "; 33 var_dump($entity->systemId); 34 echo "notationName: "; 35 var_dump($entity->notationName); 36 echo "actualEncoding: "; 37 var_dump($entity->actualEncoding); 38 echo "encoding: "; 39 var_dump($entity->encoding); 40 echo "version: "; 41 var_dump($entity->version); 42 echo "\n"; 43} 44?> 45--EXPECTF-- 46Entity name: sampleExternalPublicWithNotationName1 47publicId: string(9) "public id" 48systemId: string(14) "external.stuff" 49notationName: string(5) "stuff" 50actualEncoding: 51Deprecated: Property DOMEntity::$actualEncoding is deprecated in %s on line %d 52NULL 53encoding: 54Deprecated: Property DOMEntity::$encoding is deprecated in %s on line %d 55NULL 56version: 57Deprecated: Property DOMEntity::$version is deprecated in %s on line %d 58NULL 59 60Entity name: sampleExternalPublicWithNotationName2 61publicId: string(0) "" 62systemId: string(14) "external.stuff" 63notationName: string(5) "stuff" 64actualEncoding: 65Deprecated: Property DOMEntity::$actualEncoding is deprecated in %s on line %d 66NULL 67encoding: 68Deprecated: Property DOMEntity::$encoding is deprecated in %s on line %d 69NULL 70version: 71Deprecated: Property DOMEntity::$version is deprecated in %s on line %d 72NULL 73 74Entity name: sampleExternalPublicWithoutNotationName1 75publicId: string(9) "public id" 76systemId: string(14) "external.stuff" 77notationName: string(0) "" 78actualEncoding: 79Deprecated: Property DOMEntity::$actualEncoding is deprecated in %s on line %d 80NULL 81encoding: 82Deprecated: Property DOMEntity::$encoding is deprecated in %s on line %d 83NULL 84version: 85Deprecated: Property DOMEntity::$version is deprecated in %s on line %d 86NULL 87 88Entity name: sampleExternalPublicWithoutNotationName2 89publicId: string(0) "" 90systemId: string(14) "external.stuff" 91notationName: string(0) "" 92actualEncoding: 93Deprecated: Property DOMEntity::$actualEncoding is deprecated in %s on line %d 94NULL 95encoding: 96Deprecated: Property DOMEntity::$encoding is deprecated in %s on line %d 97NULL 98version: 99Deprecated: Property DOMEntity::$version is deprecated in %s on line %d 100NULL 101 102Entity name: sampleExternalSystemWithNotationName 103publicId: NULL 104systemId: string(14) "external.stuff" 105notationName: string(5) "stuff" 106actualEncoding: 107Deprecated: Property DOMEntity::$actualEncoding is deprecated in %s on line %d 108NULL 109encoding: 110Deprecated: Property DOMEntity::$encoding is deprecated in %s on line %d 111NULL 112version: 113Deprecated: Property DOMEntity::$version is deprecated in %s on line %d 114NULL 115 116Entity name: sampleExternalSystemWithoutNotationName 117publicId: NULL 118systemId: string(14) "external.stuff" 119notationName: string(0) "" 120actualEncoding: 121Deprecated: Property DOMEntity::$actualEncoding is deprecated in %s on line %d 122NULL 123encoding: 124Deprecated: Property DOMEntity::$encoding is deprecated in %s on line %d 125NULL 126version: 127Deprecated: Property DOMEntity::$version is deprecated in %s on line %d 128NULL 129 130Entity name: sampleInternalEntity 131publicId: NULL 132systemId: NULL 133notationName: NULL 134actualEncoding: 135Deprecated: Property DOMEntity::$actualEncoding is deprecated in %s on line %d 136NULL 137encoding: 138Deprecated: Property DOMEntity::$encoding is deprecated in %s on line %d 139NULL 140version: 141Deprecated: Property DOMEntity::$version is deprecated in %s on line %d 142NULL 143