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