Proszę o pomoc w zastosowaniu klasy.
a oto ona
<?php class array2xml { 'encoding' => 'ISO-8859-15', 'ino' => 'http://namespaces.softwareag.com/tamino/response2' ) ); function array2xml( $array ) { $this->array = $array; $this->dom = domxml_new_doc(\"1.0\"); } function setEncoding( $enc ) { $this->config['encoding'] = ( $enc != '' ) ? $enc : $this->config['encoding']; } function addNamespaces( $assoc ) { } function getResult($format = TRUE) { $root_element = $this->dom->create_element($doc_root); $this->_recArray2Node($root_element, $this->array[$doc_root]); $this->dom->append_child($root_element); // check for namespaces ? add each to doc foreach ($this->used_namespaces as $ns) $root_element->add_namespace($this->config[\"xmlns\"][ $ns ], $ns); // <b>Warning</b>: dump_mem(): xmlDocDumpFormatMemoryEnc: Failed to identify encoding handler for character set 'ISO-8859-15' return $this->dom->dump_mem($format,$this->config['encoding']); } function _recArray2Node( $parent_node, $array ) { foreach ($array as $key => $value) { $org_key = $key; if ( !$key ) $key = $ns; elseif ($ns == \"xmlns\") { break; }else{ if ( $this->config[\"xmlns\"][ $ns ] ) { $this->used_namespaces[] = $ns; $key = $ns.\":\".$key; } else } { // attribute $parent_node->set_attribute( $key, $value ); continue; } { // text node // check if valid text & not empty { $element = $this->dom->create_text_node($value); $parent_node->append_child($element); } continue; } else { // child node // check for enumeration $enum = FALSE; { { // enumeration of multiple nodes $enum = TRUE; $element = $this->dom->create_element($key); $this->_recArray2Node($element, $v); $parent_node->append_child($element); } } // check for enumeration if ( $enum == FALSE ) { $element = $this->dom->create_element($key); $this->_recArray2Node($element, $value); $parent_node->append_child($element); } } } } } ?>
skrobnąłem mały skrpycik test.php ale nie działa bo wynik jest obiektem a nie xml-em
<?php include(\"class.array2xml.php\"); $tbl[0]=\"asds\"; $tbl[1]=\"fsdfsd\"; $tbl[2]=\"sfds\"; $ar = new array2xml($tbl); ?>