Classes/ViewHelpers/ResultViewHelper.php
protected function XMLForLocations($locations)
    {
        $XML = new \DOMDocument();
        $locationsElement = $XML->createElement('locations');
        $XML->appendChild($locationsElement);

        foreach ($locations as $location) {
            $locationElement = $XML->createElement('location');
            $locationsElement->appendChild($locationElement);

            // copy attributes
            if (array_key_exists('attrs', $location)) {
                foreach ($location['attrs'] as $attributeName => $attributeContent) {
                    $locationElement->setAttribute($attributeName, $attributeContent);
                }
            }

            // copy child elements
            if (array_key_exists('ch', $location)) {
                foreach ($location['ch'] as $fieldName => $fields) {
                    foreach ($fields as $field) {
                        $childElement = $XML->createElement($fieldName);
                        $locationElement->appendChild($childElement);
                        $childElement->appendChild($XML->createTextNode($field['values'][0]));

                        // copy attributes of child elements
                        if (array_key_exists('attr', $field)) {
                            foreach ($field['attr'] as $attributeName => $attributeContent) {
                                $childElement->setAttribute($attributeName, $attributeContent);
                            }
                        }
                    }
                }
            }
        }

        return $XML;
    }
protected function XMLForLocations($locations)
    {
        $XML = new \DOMDocument();
        $locationsElement = $XML->createElement('locations');
        $XML->appendChild($locationsElement);

        foreach ($locations as $location) {
            $locationElement = $XML->createElement('location');
            $locationsElement->appendChild($locationElement);

            // copy attributes
            if (array_key_exists('attrs', $location)) {
                foreach ($location['attrs'] as $attributeName => $attributeContent) {
                    $locationElement->setAttribute($attributeName, $attributeContent);
                }
            }

            // copy child elements
            if (array_key_exists('ch', $location)) {
                foreach ($location['ch'] as $fieldName => $fields) {
                    foreach ($fields as $field) {
                        $childElement = $XML->createElement($fieldName);
                        $locationElement->appendChild($childElement);
                        $childElement->appendChild($XML->createTextNode($field['values'][0]));

                        // copy attributes of child elements
                        if (array_key_exists('attr', $field)) {
                            foreach ($field['attr'] as $attributeName => $attributeContent) {
                                $childElement->setAttribute($attributeName, $attributeContent);
                            }
                        }
                    }
                }
            }
        }

        return $XML;
    }
protected function XMLForLocations ( $ locations ) { $ XML = new \ DOMDocument ( ) ; $ locationsElement = $ XML -> createElement ( 'locations' ) ; $ XML -> appendChild ( $ locationsElement ) ; foreach ( $ locations as $ location ) { $ locationElement = $ XML -> createElement ( 'location' ) ; $ locationsElement -> appendChild ( $ locationElement ) ; // copy attributes if ( array_key_exists ( 'attrs' , $ location ) ) { foreach ( $ location [ 'attrs' ] as $ attributeName => $ attributeContent ) { $ locationElement -> setAttribute ( $ attributeName , $ attributeContent ) ; } } // copy child elements if ( array_key_exists ( 'ch' , $ location ) ) { foreach ( $ location [ 'ch' ] as $ fieldName => $ fields ) { foreach ( $ fields as $ field ) { $ childElement = $ XML -> createElement ( $ fieldName ) ; $ locationElement -> appendChild ( $ childElement ) ; $ childElement -> appendChild ( $ XML -> createTextNode ( $ field [ 'values' ] [ 0 ] ) ) ; // copy attributes of child elements if ( array_key_exists ( 'attr' , $ field ) ) { foreach ( $ field [ 'attr' ] as $ attributeName => $ attributeContent ) { $ childElement -> setAttribute ( $ attributeName , $ attributeContent ) ; } } } } } } return $ XML ; }
Returns XML representing the passed locations.
@param array $locations
@return \DOMDocument
Returns XML representing the passed locations .