Using this on a standard XML document will ignore a lot of data. Namespaces and Attributes are ignored, if here are two elements with the same name only the last will be in the output. If an element has child elements, all text child nodes will be ignored. See the other serializers, to keep this data. This serializer recognizes attributes from the JsonDOM namespaces. If you import an JSON to a DOM in FluentDOM, the additional information is stored in these attributes (types, names, ...) Here is a example of an XML: true 42 Foo <_ json:type="number">21
Inheritance: implements JsonSerializable
Beispiel #1
0
 protected function getNamespaces(\DOMElement $node)
 {
     $result = [];
     foreach (parent::getNamespaces($node) as $prefix => $uri) {
         $attribute = new \stdClass();
         $attribute->{'#name'} = '@' . $prefix;
         $attribute->{'#text'} = $uri;
         $attribute->{'#children'} = [];
         $result[] = $attribute;
     }
     return $result;
 }