public function saveXml($extension_txt_id, $template_id_src) { $layouts = $this->getLayoutsByTemplate($template_id_src); $xml_data = array(); foreach ($layouts as $i => $layout) { $xml_data['layout'][$i] = array('name' => $layout['layout_name'], 'template_id' => $extension_txt_id, 'type' => $this->_getTextLayoutType($layout['layout_type']), 'pages' => array('page' => $this->_getLayoutPages4Xml($layout['layout_id'])), 'blocks' => $this->_getLayoutBlocks4Xml($layout['layout_id'])); } $xml = Array2XML::createXML('template_layouts', $xml_data); $xml = $xml->saveXML(); $path = DIR_EXT . $extension_txt_id . '/layout.xml'; if ($xml) { $result = file_put_contents($path, $xml); if ($result) { // and put xml-import call into install.php $import_call = "\n\$layout = new ALayoutManager();\n\$layout->loadXml(array('file' => DIR_EXT.'" . $extension_txt_id . "/layout.xml'));"; $code = file_get_contents(DIR_EXT . $extension_txt_id . '/install.php'); $code = str_replace($import_call, '', $code) . $import_call; file_put_contents(DIR_EXT . $extension_txt_id . '/install.php', $code); // and into uninstall.php $import_call = "\n\$layout = new ALayoutManager('" . $extension_txt_id . "');\n\$layout->deleteTemplateLayouts();"; $code = file_get_contents(DIR_EXT . $extension_txt_id . '/uninstall.php'); $code = str_replace($import_call, '', $code) . $import_call; file_put_contents(DIR_EXT . $extension_txt_id . '/uninstall.php', $code); return true; } else { $this->error = "Can't save extension " . $path . ". Unknown cause."; return false; } } else { return false; } }
function get_quota_data($data) { $response = array("ns1_get_quota_data_response" => array("bucket" => array(array("bucket_id" => "routing", "name" => "planing", "day" => array("date" => "2014-02-04", "quota" => "456", "close_time" => "2014-02-04 13:51:00", "max_available" => "24150", "other_activities" => "175", "used" => "225", "used_quota_percent" => "49.34210526", "count" => "5", "time_slot" => array(array("label" => "08-12", "quota_percent" => "55", "min_quota" => "67", "quota" => "251", "status" => "4", "max_available" => "8400", "other_activities" => "47", "used" => "90", "used_quota_percent" => "35.85657371", "count" => "2", "category" => array(array("label" => "04", "quota_percent" => "6.81818199", "quota" => "9", "stop_booking_at" => "12", "close_time" => "2014-02-04 23:30:00", "max_available" => "5040", "used" => "45", "used_quota_percent" => "500", "count" => "1"), array("label" => "6", "quota_percent" => "93.1818161", "quota" => "123", "stop_booking_at" => "2", "max_available" => "5280", "used" => "45", "used_quota_percent" => "36.58536585", "count" => "1", "work_zone" => array("label" => "98", "status" => "1", "closed_at" => "2014-02-03 08:14:37"))), "total" => array("quota" => "132", "max_available" => "10320", "used" => "90", "count" => "2")), array("label" => "12-17", "quota_percent" => "45", "min_quota" => "567", "quota" => "567", "close_time" => "2014-02-04 16:30:00", "max_available" => "10500", "other_activities" => "89", "used" => "135", "used_quota_percent" => "23.80952381", "count" => "3", "category" => array(array("label" => "04", "quota_percent" => "91.76470947", "quota" => "234", "stop_booking_at" => "7", "max_available" => "6300", "used" => "45", "used_quota_percent" => "19.23076923", "count" => "1"), array("label" => "6", "quota_percent" => "8.23529434", "quota" => "21", "stop_booking_at" => "4", "max_available" => "6600", "used" => "90", "used_quota_percent" => "428.57142857", "count" => "2")), "total" => array("quota" => "255", "max_available" => "12900", "used" => "135", "count" => "3"))), "total" => array("quota" => "818", "max_available" => "18900", "other_activities" => "136", "used" => "225", "count" => "5"))), array("bucket_id" => "planing", "name" => "planing 1", "day" => "")))); $xml = \Array2XML::createXML('soap', $response); $string = $xml->saveXML(); return $string; }
/** * Generate service output json format * @param ApiResult $result */ public static function generateOutput($result) { assert('$result instanceof ApiResult'); $data = $result->convertToArray(); $xml = Array2XML::createXML('zurmoMessage', $data); echo $xml->saveXML(); return; }
/** * Convert an Array to XML * @param string $node_name - name of the root node to be converted * @param array $arr - aray to be converterd * @return DomDocument */ public static function &createXML($node_name, $arr = array()) { $xml = self::getXMLRoot(); $xml->appendChild(self::convert($node_name, $arr)); self::$xml = null; // clear the xml node in the class for 2nd time use. return $xml; }
/** * nv_CreateXML_bannerPlan() * * @return */ function nv_CreateXML_bannerPlan() { global $db, $global_config; $pattern = $global_config['idsite'] ? '/^site\\_' . $global_config['idsite'] . '\\_bpl\\_([0-9]+)\\.xml$/' : '/^bpl\\_([0-9]+)\\.xml$/'; $files = nv_scandir(NV_ROOTDIR . '/' . NV_DATADIR, $pattern); if (!empty($files)) { foreach ($files as $file) { nv_deletefile(NV_ROOTDIR . '/' . NV_DATADIR . '/' . $file); } } include NV_ROOTDIR . '/includes/class/array2xml.class.php'; $sql = 'SELECT * FROM ' . NV_BANNERS_GLOBALTABLE . '_plans WHERE act = 1'; $result = $db->query($sql); while ($row = $result->fetch()) { $id = intval($row['id']); if ($global_config['idsite']) { $xmlfile = NV_ROOTDIR . '/' . NV_DATADIR . '/site_' . $global_config['idsite'] . '_bpl_' . $id . '.xml'; } else { $xmlfile = NV_ROOTDIR . '/' . NV_DATADIR . '/bpl_' . $id . '.xml'; } $plan = array(); $plan['id'] = $id; $plan['lang'] = $row['blang']; $plan['title'] = $row['title']; if (!empty($row['description'])) { $plan['description'] = $row['description']; } $plan['form'] = $row['form']; $plan['width'] = $row['width']; $plan['height'] = $row['height']; $query2 = 'SELECT * FROM ' . NV_BANNERS_GLOBALTABLE . '_rows WHERE pid = ' . $id . ' AND (exp_time > ' . NV_CURRENTTIME . ' OR exp_time = 0 ) AND act = 1'; if ($row['form'] == 'sequential') { $query2 .= ' ORDER BY weight ASC'; } $plan['banners'] = array(); $result2 = $db->query($query2); while ($row2 = $result2->fetch()) { $plan['banners'][] = array('id' => $row2['id'], 'title' => $row2['title'], 'clid' => $row2['clid'], 'file_name' => $row2['file_name'], 'imageforswf' => $row2['imageforswf'], 'file_ext' => $row2['file_ext'], 'file_mime' => $row2['file_mime'], 'file_width' => $row2['width'], 'file_height' => $row2['height'], 'file_alt' => $row2['file_alt'], 'file_click' => $row2['click_url'], 'target' => $row2['target'], 'publ_time' => $row2['publ_time'], 'exp_time' => $row2['exp_time']); } if (sizeof($plan['banners'])) { $array2XML = new Array2XML(); $array2XML->saveXML($plan, 'plan', $xmlfile, $encoding = $global_config['site_charset']); } } }
public function optOut($email) { //Build request data. $message = array('SITE_ID' => '2010003057', 'MLID' => 194503, 'DATA' => array(array('@attributes' => array('type' => 'extra', 'id' => 'password'), '@value' => $this->_password), array('@attributes' => array('type' => 'email'), '@value' => $email), array('@attributes' => array('type' => 'extra', 'id' => 'state'), '@value' => 'unsubscribed'))); //Convert to XML. $xml = Array2XML::createXML('DATASET', $message); $response = $this->_httpPost('record', 'update', $xml->saveXML()); return $response->TYPE == 'success' ? true : false; }
/** * Sample xml file */ public function actionSample() { header("Content-type: application/octet-stream"); header("Content-Disposition: attachment; filename=\"sample.xml\""); $productsList = array(); $productsList['product'] = array('name' => 'Мой товара', 'price' => 10, 'type' => 'Ваш тип товара', 'manufacturer' => 'Бренд', 'image' => 'http://example.com/myimage.jpg'); $xml = Array2XML::createXML('products', $productsList); echo $xml->saveXML(); Yii::app()->end(); }
/** * nv_CreateXML_bannerPlan() * * @return */ function nv_CreateXML_bannerPlan() { global $db, $global_config; $files = nv_scandir(NV_ROOTDIR . '/' . NV_DATADIR, "/^bpl\\_([0-9]+)\\.xml\$/"); if (!empty($files)) { foreach ($files as $file) { nv_deletefile(NV_ROOTDIR . '/' . NV_DATADIR . '/' . $file); } } include NV_ROOTDIR . '/includes/class/array2xml.class.php'; $sql = "SELECT * FROM `" . NV_BANNERS_PLANS_GLOBALTABLE . "` WHERE `act` = 1"; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $id = intval($row['id']); $xmlfile = NV_ROOTDIR . '/' . NV_DATADIR . '/bpl_' . $id . '.xml'; $plan = array(); $plan['id'] = $id; $plan['lang'] = $row['blang']; $plan['title'] = $row['title']; if (!empty($row['description'])) { $plan['description'] = $row['description']; } $plan['form'] = $row['form']; $plan['width'] = $row['width']; $plan['height'] = $row['height']; $query2 = "SELECT * FROM `" . NV_BANNERS_ROWS_GLOBALTABLE . "` WHERE `pid` = " . $id . " AND (`exp_time` > " . NV_CURRENTTIME . " OR `exp_time` = 0 ) AND `act` = 1"; if ($row['form'] == "sequential") { $query2 .= " ORDER BY `weight` ASC"; } $result2 = $db->sql_query($query2); $numrows2 = $db->sql_numrows($result2); if (empty($numrows2)) { continue; } $plan['banners'] = array(); while ($row2 = $db->sql_fetchrow($result2)) { $plan['banners'][] = array('id' => $row2['id'], 'title' => $row2['title'], 'clid' => $row2['clid'], 'file_name' => $row2['file_name'], 'file_ext' => $row2['file_ext'], 'file_mime' => $row2['file_mime'], 'file_width' => $row2['width'], 'file_height' => $row2['height'], 'file_alt' => $row2['file_alt'], 'file_click' => $row2['click_url']); } $array2XML = new Array2XML(); $array2XML->saveXML($plan, 'plan', $xmlfile, $encoding = $global_config['site_charset']); } }
private function prepareData() { require_once 'classXML2Array.php'; $xml = Array2XML::createXML('blocks', $this->blocksData); $file = $this->sitePath . 'tmp/' . date('Y-m-d', time()) . '.xml'; ob_start(); echo $xml->saveXML(); $data = ob_get_contents(); ob_end_clean(); $fp = @fopen($file, "w"); @fwrite($fp, $data); @fclose($fp); }
function setDocument($xml) { $this->document = $this->XmlToArray($xml); unset($this->document['ClinicalDocument']['@attributes']); Array2XML::init('1.0', 'UTF-8', true, ['xml-stylesheet' => 'type="text/xsl" href="' . URL . '/lib/CCRCDA/schema/cda2.xsl"']); $data = ['@attributes' => ['xmlns' => 'urn:hl7-org:v3', 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', 'xsi:schemaLocation' => 'urn:hl7-org:v3 CDA.xsd']]; foreach ($this->document['ClinicalDocument'] as $i => $com) { $data[$i] = $com; } // Building the document $this->styledXml = Array2XML::createXML('ClinicalDocument', $data)->saveXML(); unset($data); $this->index = []; foreach ($this->document['ClinicalDocument']['component']['structuredBody']['component'] as $index => $component) { $code = isset($component['section']['code']['@attributes']['code']) ? $component['section']['code']['@attributes']['code'] : ''; //Advance Directives ??? switch ($code) { case '48765-2': $this->index['allergies'] = $index; break; case '10160-0': $this->index['medications'] = $index; break; case '11450-4': $this->index['problems'] = $index; break; case '47519-4': $this->index['procedures'] = $index; break; case '30954-2': $this->index['results'] = $index; break; case '46240-8': $this->index['encounters'] = $index; break; case '51847-2': $this->index['assessments'] = $index; break; case '46239-0': $this->index['chiefcomplaint'] = $index; break; default: $tplId = isset($component['section']['templateId']['@attributes']['root']) ? $component['section']['templateId']['@attributes']['root'] : ''; if ($tplId == '2.16.840.1.113883.10.20.22.2.21.1') { $this->index['advancedirectives'] = $index; } break; } } }
/** * Convert an Array to XML * @param string $node_name - name of the root node to be converted * @param array $arr - aray to be converterd * @return DomDocument */ public static function &createXML($node_name, $arr = array()) { $xml = self::getXMLRoot(); /****** PATCH ***/ //http://www.lalit.org/lab/convert-php-array-to-xml-with-attributes/#comment-23469 // remove // $xml->appendChild(self::convert($node_name, $arr)); // add if (count($arr) > 1) { $xml->appendChild(self::convert($node_name, $arr)); } else { $root_element = @array_pop(array_keys($arr)); $xml->insertBefore(self::convert($root_element, $arr[$root_element])); } // fin add self::$xml = null; // clear the xml node in the class for 2nd time use. return $xml; }
public function saveconfigAction() { require_once Mage::getBaseDir() . '/app/code/local/Etheme/Evoqueconfig/lib/Array2Xml.php'; $name = $this->getRequest()->getParam('name'); $store = $this->getRequest()->getParam('store'); $scope = $store ? 'stores' : 'default'; $sections = array('evoqueconfig', 'evoquecolors', 'evoquelayout', 'evoqueflex'); $data = array(); $data['name'] = $name; foreach ($sections as $section) { $data['sections'][$section] = Mage::getStoreConfig($section, $store); } $xml = Array2XML::createXML('config', $data); $file = Mage::getBaseDir() . '/ev_skins/' . $data['name'] . '.xml'; $content = $xml->saveXML(); @file_put_contents($file, $content); Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('evoqueconfig')->__('New preset configuration saved successfully. You can use it from "Load preset configuration" and find in folder ' . $file)); $this->getResponse()->setRedirect($this->getUrl("*/*/")); }
public function array2xml() { require_once BASEPATH . '../application/third_party/array2xml/Array2XML.php'; /* <?xml version="1.0" encoding="UTF-8"?> <head/> <books type="fiction"> <book author="George Orwell"> <title>1984</title> </book> <book author="Isaac Asimov"> <title><![CDATA[Foundation]]></title> <price>$15.61</price> </book> <book author="Robert A Heinlein"> <title><![CDATA[Stranger in a Strange Land]]></title> <price discount="10%">$18.00</price> </book> </books> */ $books = array('@attributes' => array('type' => 'fiction'), 'book' => array(array('@attributes' => array('author' => 'George Orwell'), 'title' => '1984'), array('@attributes' => array('author' => 'Isaac Asimov'), 'title' => array('@cdata' => 'Foundation'), 'price' => '$15.61'), array('@attributes' => array('author' => 'Robert A Heinlein'), 'title' => array('@cdata' => 'Stranger in a Strange Land'), 'price' => array('@attributes' => array('discount' => '10%'), '@value' => '$18.00')))); $xml = Array2XML::createXML('books', $books); echo $xml->saveXML(); }
//if( $rowSNMP[0].$rowSNMP[1].$rowSNMP[2]=="192") echo "yes"; else echo "no"; //if( substr($rowSNMP,0,9)=="192.168.1" ) //$sps=substr($rowSNMP,12); //if( in_array(substr($rowSNMP,8,3),$_HOSTEL_NETS) && $sps!=="1" && $sps!=="0" && $sps!=="255") //{ $rowSNMP_s = "k" . str_replace(".", "", $rowSNMP); $ips[$rowSNMP_s] = array(); //IpAddress: //if(!file_exists("./ipdate/".$rowSNMP.".ip")) file_put_contents("./ipdate/".$rowSNMP.".ip","{$rowSNMP} {$date}"); if (!$array2[$rowSNMP_s]['ip']) { $ips[$rowSNMP_s]['ip'] = $rowSNMP; } else { $ips[$rowSNMP_s]['ip'] = $array2[$rowSNMP_s]['ip']; } if (!$array2[$rowSNMP_s]['fixdate']) { $ips[$rowSNMP_s]['fixdate'] = $date; } else { $ips[$rowSNMP_s]['fixdate'] = $array2[$rowSNMP_s]['fixdate']; } $ips[$rowSNMP_s]['lastdate'] = $date; // } } $result = array_merge($array2, $ips); //print_r($result); $converter = new Array2XML(); $xmlStr = $converter->convert($result); file_put_contents($command['ipdatefile'], $xmlStr); $n = count($result); $time = microtime(true) - $start; echo "work done ({$n} rows) []"; printf('Скрипт выполнялся %.4F сек.', $time);
function translateOneNode($currentNodeID, $to_languages, $content_type) { global $db, $XMLarray, $error_log; $separator = "7543545165934149"; // Fetch a node from Drupal if a copy does not already exist in sources dir. // $xml_MASTER is the original English-language version // $xml is the copy that will be translated $fn = getcwd() . "/sources/SOURCE_" . $currentNodeID . ".XML"; if (file_exists($fn)) { $xml_MASTER = file_get_contents($fn); if ($content_type == "page") { // Remove <teaser> from "page". The "teaser" is created by truncating the <body>, resulting in invalid XML $xml_MASTER = preg_replace("|<teaser>.*?</teaser>|us", "<teaser></teaser>", $xml_MASTER); } } else { $xml_MASTER = fetchOneNode($currentNodeID); if ($content_type == "page") { $xml_MASTER = preg_replace("|<teaser>.*?</teaser>|us", "<teaser></teaser>", $xml_MASTER); } $fh = fopen($fn, "w"); fwrite($fh, $xml_MASTER); fclose($fh); } foreach ($to_languages as $to_language) { $query = "select drupal_code from sovee.languages where sovee_code = '" . $to_language . "'"; $result = mysql_query($query, $db); while ($row = mysql_fetch_assoc($result)) { $drupalLanguageCode = $row['drupal_code']; } mysql_free_result($result); echo "\n=====================================================================================\n========== ==========\n. . . Translating node {$currentNodeID} ({$content_type}) into {$to_language} . . . \n"; $error_IncompleteNodeFlag = 0; $xml = $xml_MASTER; // Create a copy of the master, to be translated // Convert XML to array $XMLarray = XML2Array::createArray($xml); // Get info about the node // Requested info is placed in the $requestedTags array // and returned in the assoc. array info() $requestedTags = array("type", "tnid"); $info = getXMLinfo($xml, $requestedTags); $derivedContentType = $info['type']; // Build list of containers to parse for the given content_type. $query = "select DISTINCT sovee.node_fields.name from sovee.content_type \nLEFT JOIN sovee.field_map ON sovee.content_type.id = sovee.field_map.content_id\nLEFT JOIN sovee.node_fields ON sovee.node_fields.id = sovee.field_map.field_id\nWHERE sovee.content_type.name = '" . $derivedContentType . "'"; $result = mysql_query($query, $db); while ($row = mysql_fetch_assoc($result)) { $containerArrayTemplate[] = $row['name']; } mysql_free_result($result); // Walk throught the array, extract the specified containers, translate // and replace in the array // All array elements are assumed to be in the [node_export][node] array // $containerArrayTemplate = array("body", "title", "teaser", "field_product_subtitle|n*|value", "field_warranty|n*|value", "field_product_education|n*|value", // "field_prod_man_docs_link|n*|title", // "field_did_you_know|n*|value", "field_product_benefits|n*|value", "nodewords|copyright|value", "nodewords|dcterms.contributor|value", // "nodewords|dcterms.title|value", "nodewords|description|value", "nodewords|keywords|value" ); $containerArray = expandTemplate($containerArrayTemplate); $allContainers = "<div>{$separator}"; foreach ($containerArray as $oneContainer) { echo "\nProcessing container {$oneContainer}\n"; $parents = explode("|", $oneContainer); array_unshift($parents, "node_export", "node"); #echo "Parents: "; #print_r($parents); $XMLfragment = drupal_array_get_nested_value($XMLarray, $parents); if (is_array($XMLfragment)) { $XMLfragment = ""; } $translatedFragment = ""; $patterns = array("|^<div>|us", "|</div>\$|us"); // The "|u" flag enables multibyte support $replacements = array("", ""); if (strlen(trim($XMLfragment)) > 0 and !is_array($XMLfragment)) { $XMLfragment = "<div>" . $XMLfragment . "</div>"; // Encapsulate in dummy <div> to satisfy Sovee translator // echo "ORIGINAL Fragment = |$XMLfragment|\n"; } else { echo "Original Fragment |{$XMLfragment}| is empty -- skipping.\n"; } $allContainers .= $XMLfragment . $separator; // Add at the end of each container to faciliate preg_split } // ------- End of foreach($containerArray as $oneContainer) $allContainers .= "</div>"; // Translate the entire node if target language is not English echo "TO_LANGUAGE = {$to_language}\n"; $xxx = substr($to_language, 0, 2); echo "SUBSTR = |{$xxx}|\n"; $sovee_to_language = $to_language; if (substr($to_language, 0, 2) != "en") { if ($to_language == "es-419") { $sovee_to_language = "es-es"; } // Use standard Spanish for Latin America echo "Sending strings to Sovee . . . \n"; $translatedFragmentAry = translateFrag($allContainers, $currentNodeID, "FULL NODE", $to_language); // Perform the translation $translatedFragment = $translatedFragmentAry['content']; $translatedFragmentError = $translatedFragmentAry['error_count']; // Count of translation errors. 0 = success $error_IncompleteNodeFlag += $translatedFragmentError; } else { echo "English-to-English: No translation needed.\n"; $translatedFragment = $allContainers; $translatedFragmentError = 0; } // print_r($translatedFragmentAry); $separatorPattern = "/{$separator}/u"; $translatedNodeAry = preg_split($separatorPattern, $translatedFragment); // print_r($translatedNodeAry); $translatedContentPointer = 1; reset($containerArray); foreach ($containerArray as $oneContainer) { $parents = explode("|", $oneContainer); array_unshift($parents, "node_export", "node"); $stripped = trim(preg_replace($patterns, $replacements, $translatedNodeAry[$translatedContentPointer])); // Remove the leading and trailing <div>s from the node fragments // Special handling for page_title, which can be a string or an array if ($oneContainer == "page_title" and $stripped == "Array") { $pageTitleParents1 = array('node_export', 'node', 'page_title', 'value'); $pageTitleParents2 = array('node_export', 'node', 'page_title', 'attributes', 'type'); drupal_array_set_nested_value($XMLarray, $pageTitleParents1, "FALSE"); drupal_array_set_nested_value($XMLarray, $pageTitleParents2, "boolean"); } else { if (strlen($stripped) > 0) { drupal_array_set_nested_value($XMLarray, $parents, $stripped); } } $translatedContentPointer++; } // HTML-Encode any info in the <data> container // $dataParents = array('node_export', 'node', 'data'); // $dataFragment = htmlentities(drupal_array_get_nested_value($XMLarray, $dataParents)); // drupal_array_set_nested_value($XMLarray, $dataParents, $dataFragment); #echo "TRANSLATED XML ARRAY:"; #print_r($XMLarray); // Does an older version of this translated node exist? // If yes, return the node# and alias in an array // otherwise, $oldNodeID_ary['number'] == '' $oldNodeID_ary = findOldTranslation($currentNodeID, $to_language); $oldNodeID = $oldNodeID_ary['number']; $oldNodeIDalias = $oldNodeID_ary['url_alias']; if ($oldNodeID != "") { echo "\nFound old node number -- old={$oldNodeID}\n"; } if ($oldNodeIDalias != "") { echo "\nFound old node number alias -- old={$oldNodeIDalias}\n"; } // Update the nid and tnid fields // For new nodes, nid='' // and tnid = the current nid value $XMLarray['node_export']['node']['tnid'] = $currentNodeID; $XMLarray['node_export']['node']['nid'] = $oldNodeID; // $XMLarray['node_export']['node']['language'] = $oldNodeID['drupal_lang_code']; $XMLarray['node_export']['node']['language'] = $drupalLanguageCode; // // // $XMLarray['node_export']['node']['path'] = $oldNodeID['url_alias']; if (isset($XMLarray['node_export']['node']['xmlsitemap']['language'])) { // $XMLarray['node_export']['node']['xmlsitemap']['language'] = $oldNodeID['drupal_lang_code']; $XMLarray['node_export']['node']['xmlsitemap']['language'] = $drupalLanguageCode; } //echo "XMLARRAY = \n"; //print_r($XMLarray); $FOO = $XMLarray['node_export']['node']['nodewords']['location']['latitude']; $BAR = $XMLarray['node_export']['node']['nodewords']['location']['longitude']; echo "FOO = {$FOO}\nBAR = {$BAR}\n"; // If lat or long > 8 chars, set to zero, otherwise node will not import if (isset($XMLarray['node_export']['node']['nodewords']['location']['latitude'])) { if (strlen($XMLarray['node_export']['node']['nodewords']['location']['latitude']) > 8) { $XMLarray['node_export']['node']['nodewords']['location']['latitude'] = 0; } } if (isset($XMLarray['node_export']['node']['nodewords']['location']['longitude'])) { if (strlen($XMLarray['node_export']['node']['nodewords']['location']['longitude']) > 8) { $XMLarray['node_export']['node']['nodewords']['location']['longitude'] = 0; } } // Adjust the menu references $this_plid = $XMLarray['node_export']['node']['menu']['plid']; $this_menu_name = $XMLarray['node_export']['node']['menu']['menu_name']; if ($this_menu_name == "primary-links") { $mquery = "SELECT t_menuid from sovee.menus LEFT JOIN sovee.languages on sovee.menus.language_code = sovee.languages.id WHERE drupal_code = \"" . $drupalLanguageCode . "\" and Eng_menuid = \"" . $this_plid . "\""; echo "MQ = {$mquery}\n"; $rmquery = mysql_query($mquery, $db); $err_msg = trim(mysql_error($db)); if (strlen($err_msg) > 0) { echo "{$mquery}\n{$err_msg}\n\n\n"; } while ($m1 = mysql_fetch_assoc($rmquery)) { $newPlid = $m1['t_menuid']; $XMLarray['node_export']['node']['menu']['plid'] = $newPlid; } mysql_free_result($rmquery); } // Convert array back to XML $encoding = "UTF-8"; $xmlVersion = "1.0"; Array2XML::init($xmlVersion, $encoding); $xmlobj = Array2XML::createXML('DELETE_ME', $XMLarray); // Convert a PHP array to XML, using 'DELETE_ME' as the root_node_name $translated_xml = $xmlobj->saveXML(); // Returned object is of type DOMDocument $translated_xml = preg_replace("/<[\\/]?DELETE_ME>[\n]/u", "", $translated_xml); $fn = getcwd() . "/TRANSLATED_" . $drupalLanguageCode . "_" . $currentNodeID . ".XML"; echo "WRITING {$fn}\n"; $fh = fopen($fn, "w"); fwrite($fh, $translated_xml); fclose($fh); // If node translation was successful, // import the translated node back into Drupal if ($error_IncompleteNodeFlag == 0) { $cmd = "/usr/bin/drush --root=/var/www/pressflow node-export-import --file={$fn}"; echo "COMMAND = {$cmd}\n"; $success = `{$cmd}`; $error = "DRUSH IMPORT RESULTS: {$success}\n"; echo $error; fwrite($error_log, $error); $cmd = "/bin/rm {$fn}"; #$success = `$cmd`; $q1 = "INSERT INTO sovee.progress (node, status, type, language) VALUES(\"" . $currentNodeID . "\", \"1\", \"" . $derivedContentType . "\", \"" . $to_language . "\") ON DUPLICATE KEY UPDATE status=VALUES(status)"; echo "Q1={$q1}\n"; $r1 = mysql_query($q1, $db); } else { $error = "Node {$currentNodeID} ({$content_type}) not completely translated. Not importing into Drupal.\n"; echo $error; $q1 = "INSERT INTO sovee.progress (node, status, type, language) VALUES(\"" . $currentNodeID . "\", \"0\", \"" . $derivedContentType . "\", \"" . $to_language . "\") ON DUPLICATE KEY UPDATE status=VALUES(status)"; $r1 = mysql_query($q1, $db); $err_msg = trim(mysql_error($db)); if (strlen($err_msg) > 0) { echo "{$q1}\n{$err_msg}\n\n\n"; } fwrite($error_log, $error); } echo "========== ==========\n=====================================================================================\n"; } $translated_xml_array = array('status' => $error_IncompleteNodeFlag, 'translated_xml' => $translated_xml); return $translated_xml_array; }
$metaContents = $nv_Request->get_array('metaContents', 'post'); foreach ($metaGroupsName as $key => $name) { if ($name == 'http-equiv' or $name == 'name' or $name == 'property') { $value = trim(strip_tags($metaGroupsValue[$key])); $content = trim(strip_tags($metaContents[$key])); $newArray = array('group' => $name, 'value' => $value, 'content' => $content); if (preg_match("/^[a-zA-Z0-9\\-\\_\\.\\:]+\$/", $value) and !in_array($value, $ignore) and preg_match("/^([^\\'\"]+)\$/", $content) and !in_array($newArray, $metatags['meta'])) { $metatags['meta'][] = $newArray; } } } if (file_exists($file_metatags)) { nv_deletefile($file_metatags); } if (!empty($metatags['meta'])) { $array2XML = new Array2XML(); $array2XML->saveXML($metatags, 'metatags', $file_metatags, $global_config['site_charset']); } $metaTagsOgp = (int) $nv_Request->get_bool('metaTagsOgp', 'post'); $description_length = $nv_Request->get_int('description_length', 'post'); $db->query("UPDATE " . NV_CONFIG_GLOBALTABLE . " SET config_value = '" . $metaTagsOgp . "' WHERE lang = 'sys' AND module = 'site' AND config_name = 'metaTagsOgp'"); $db->query("UPDATE " . NV_CONFIG_GLOBALTABLE . " SET config_value = '" . $description_length . "' WHERE lang = 'sys' AND module = 'site' AND config_name = 'description_length'"); nv_delete_all_cache(false); Header('Location: ' . NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=' . $op . '&rand=' . nv_genpass()); exit; } else { if (!file_exists($file_metatags)) { $file_metatags = NV_ROOTDIR . '/' . NV_DATADIR . '/metatags.xml'; } $mt = simplexml_load_file($file_metatags); $mt = nv_object2array($mt);
public static function createXmlApiCall($url, $method, $headers, $data = array()) { $xmlData = Array2XML::createXML('zurmoMessage', $data); $data = array('data' => $xmlData->saveXML()); return ApiRestHelper::createApiCall($url, $method, $headers, $data); }
/** * Override in your derivative class to do functionality before the fields are set on the object * @return boolean */ public function beforeSet() { $props = $this->getProperties(); $this->default = json_decode($props['default'], true); unset($props['default']); $this->unsetProperty('default'); /** * Cleaning first */ $configs = array(); foreach ($props['configs'] as $k => $v) { if ($k === 'modules') { /** * */ $checkChanges = array(); $i = 0; foreach ($v as $modName => $vals) { $checkChanges = array(); foreach ($vals['@attributes'] as $x => $y) { $y = trim($y); if ($x === 'name') { continue; } if (empty($y)) { continue; } $checkChanges[$x] = $y; } if (!empty($checkChanges)) { $innerChanges = array(); foreach ($vals['@attributes'] as $x => $y) { $y = trim($y); if ($x === 'name') { continue; } if (empty($y)) { continue; } $checkDefaultModConfs = $this->getModuleConfigs($vals['@attributes']['name']); if (empty($checkDefaultModConfs)) { continue; } if ($checkDefaultModConfs['@attributes'][$x] === $y) { continue; } $innerChanges[$x] = $y; } if (!empty($innerChanges)) { if (!isset($configs['modules'])) { $configs['modules'] = array(); } if (!isset($configs['modules']['module'])) { $configs['modules']['module'] = array(); } $vals['@attributes'] = $this->mergeValues($vals['@attributes'], $checkDefaultModConfs['@attributes']); $configs['modules']['module'][$i] = $vals; } } ++$i; } continue; } foreach ($v['@attributes'] as $x => $y) { $y = trim($y); if (empty($y)) { continue; } if (isset($this->default[$k]['@attributes'][$x]) && $this->default[$k]['@attributes'][$x] === $y) { continue; } $configs[$k]['@attributes'][$x] = $y; } } $this->unsetProperty('configs'); if (empty($configs)) { return $this->modx->lexicon('bbbx.config_err_no_changes'); } require_once $this->modx->bbbx->config['corePath'] . 'vendors/array2xml/Array2XML.php'; $array2xml = Array2XML::createXML('config', $configs); $xml = $array2xml->saveXML(); $xml = preg_replace('/>\\s+</', '><', $xml); $xml = str_replace('<?xml version="1.0" encoding="UTF-8"?>', '', $xml); $xml = trim($xml); $this->setProperty('xml', $xml); return !$this->hasErrors(); }
//krumo($_POST); $destacadosArrForm = array(); $campos = array("Titulo", "Texto", "Imagen", "Enlace", "TextoEnlace"); for ($i = 1; $i < (int) ($_POST['numerocampos'] + 1); $i++) { $nodo = array(); foreach ($campos as $x => $val) { $nodo[$val] = $_POST[$val . "_" . $i]; } $nodo["@attributes"] = array("id" => $_POST["id_" . $i]); $destacadosArrForm[] = $nodo; //krumo($nodo); } $Destacados = array("Destacados" => array("Destacado" => $destacadosArrForm, "@attributes" => array("noNamespaceSchemaLocation" => "Destacados.xsd"))); //krumo($Destacados); $Array2XML = Array2XML::init('1.0', 'iso-8859-1'); $outputDestXML = Array2XML::createXML('Destacados', $Destacados); $xmlString = $outputDestXML->saveXML(); $xmlString = utf8_encode($xmlString); $xmlDestino2 = $_SESSION['workfolder_webdir'] . "Destacados.xml"; $fp = fopen($xmlDestino2, 'w'); fwrite($fp, $xmlString); fclose($fp); } /*$xml = simplexml_load_file($xmlDestino, 'SimpleXMLElement',LIBXML_NOCDATA); $json = json_encode($xml); $XMLarray = json_decode($json,TRUE); krumo($XMLarray);*/ $xml = file_get_contents($xmlDestino); // por lo visto es mejor iconv si el texto puede contener caracteres como € que no estan en utf_decode //$xml=iconv("UTF-8", "ISO-8859-1//TRANSLIT", $xml); // utf8_decode para los caracteres especiales, ñ y demás
$searchEngineValue = $nv_Request->get_array('searchEngineValue', 'post'); $searchEngineActive = $nv_Request->get_array('searchEngineActive', 'post'); foreach ($searchEngineName as $key => $name) { $name = trim(strip_tags($name)); $value = trim(strip_tags($searchEngineValue[$key])); $active = intval($searchEngineActive[$key]); if (!empty($name) and !empty($value)) { $searchEngines['searchEngine'][] = array('name' => $name, 'value' => $value, 'active' => $active); } } if (file_exists($file_searchEngines)) { nv_deletefile($file_searchEngines); } if (!empty($searchEngines['searchEngine'])) { include NV_ROOTDIR . '/includes/class/array2xml.class.php'; $array2XML = new Array2XML(); $array2XML->saveXML($searchEngines, 'searchEngines', $file_searchEngines, $global_config['site_charset']); } } else { if (file_exists($file_searchEngines)) { $mt = simplexml_load_file($file_searchEngines); $mt = nv_object2array($mt); if ($mt['searchEngine_item']) { if (isset($mt['searchEngine_item'][0])) { $searchEngines['searchEngine'] = $mt['searchEngine_item']; } else { $searchEngines['searchEngine'][] = $mt['searchEngine_item']; } } } if (!empty($searchEngines['searchEngine']) and $nv_Request->isset_request('ping', 'post')) {
public static function respond($rawResponse, $format, $debug) { global $logger, $warnings_payload; $httpStatusCode = $rawResponse['httpStatusCode']; $httpStatusCodeMessage = $rawResponse['httpStatusCodeMessage']; $otherHeaders = $rawResponse['otherHeaders']; $internalStatusCode = $rawResponse['code']; $internalStatusMessage = $rawResponse['message']; $warnings = $warnings_payload; $resourceData = $rawResponse['data']; $response = array(); if ($httpStatusCode == 500) { $response['internal_status'] = array('code' => $httpStatusCode, 'message' => $httpStatusCodeMessage); } else { $response['internal_status'] = array('code' => $internalStatusCode, 'message' => $internalStatusMessage); if (!empty($warnings)) { $response['warnings'] = implode(', ', $warnings); } //TO-DO: Remove "data" key in response; directly show resource list if (!empty($resourceData)) { $response['data'] = $resourceData; } if ($debug) { $response['logs'] = $logger->getEntries(); } } ob_clean(); ob_start(); $logger->debug("***** Result: " . json_encode($response)); /* Set HTTP Status header */ $statusHeader = 'HTTP/1.0 ' . $httpStatusCode . ' ' . $httpStatusCodeMessage; header($statusHeader); header('Access-Control-Allow-Origin: *'); header("Access-Control-Allow-Credentials: true"); header('Access-Control-Allow-Headers: X-Requested-With'); header('Access-Control-Allow-Headers: Content-Type'); header('Access-Control-Allow-Methods: POST, GET, OPTIONS, DELETE, PUT'); header('Access-Control-Max-Age: 86400'); if (array_key_exists('HTTP_ACCESS_CONTROL_REQUEST_HEADERS', $_SERVER)) { header('Access-Control-Allow-Headers: ' . $_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']); } else { header('Access-Control-Allow-Headers: *'); } /* Set Other headers, if any */ if (isset($rawResponse['otherHeaders'])) { foreach ($otherHeaders as $header) { header($header); } } if (isset($format) && $format == 'xml') { header('Content-type:text/xml; charset=utf-8'); $xml = Array2XML::createXML('response', $response); $result = trim($xml->saveXML()); } else { if (isset($format) && $format == 'json') { header('Content-type:application/json; charset=utf-8'); $result = trim(json_encode($response)); } else { $result = serialize($response); } } echo $result; $logger->debug("Buffering: " . var_export(ob_get_status(true), true)); if (ob_get_length() > 0) { ob_end_flush(); ob_flush(); flush(); } return $result; }
/** * Save Plugin Configuration to XML * @param string $plugins */ public function pluginConfig($pluginchoose = false, $defaultplugin = false) { //Make config Folder and Plugin Config File writeable $this->writeDynamicScript(array('chmod -R 777 ' . APPLICATION_PATH . '/config')); //Check active Plugins $plugins = $this->parsePlugins(); $pos = 100; foreach ($plugins['available'] as $pa) { $pa['active'] = 0; $pa['pos'] = $pos++; foreach ($pluginchoose as $key => $pc) { if ($pc == $pa['name']) { $pa['active'] = 1; $pa['pos'] = $key; } } if ($defaultplugin == $pa['name']) { $pa['default'] = 1; } $newconfig['plugin'][$pa['pos']] = $pa; } ksort($newconfig['plugin']); include_once APPLICATION_PATH . '/library/array2xml.php'; $xml = Array2XML::createXML('config', $newconfig); $xml->save(APPLICATION_PATH . '/config/plugins.xml'); //Reload Plugins global $service; $service->plugins = $this->getActivePlugins(); return _('Plugin configuration updated'); }
/** * @method: * Simple functionality that uses another library to convert array to xml */ private function _array_to_xml($array) { $array = json_decode(json_encode($array), true); $xml = Array2XML::createXML('project', $array); return $xml->saveXML(); }
/** * Create XML file */ public function proccessOutput() { $result = array(); header('Content-Type: text/html;charset=UTF-8'); header('Content-type: application/xml'); header('Content-Disposition: attachment; filename="export.xml"'); header('Content-Transfer-Encoding: binary'); foreach ($this->rows as $key => $row) { // $result['products']['product'][$key] = array('@attributes' => array('id' => 125)); foreach ($row as $index => $value) { if (!empty($value)) { // $result['products'][]=array($k=>$l); $result['product'][$key][$index] = iconv('cp1251', 'utf-8', $value); } } } $xml = Array2XML::createXML('products', $result); echo $xml->saveXML(); Yii::app()->end(); }
/** * Output Query in either JSON/XML. The query data is outputted as JSON * by default * * @since 1.1 * @global $wp_query * * @param int $status_code */ public function output($status_code = 200) { global $wp_query; $format = $this->get_output_format(); status_header($status_code); do_action('give_api_output_before', $this->data, $this, $format); switch ($format) { case 'xml': require_once GIVE_PLUGIN_DIR . 'includes/libraries/array2xml.php'; $xml = Array2XML::createXML('give', $this->data); echo $xml->saveXML(); break; case 'json': header('Content-Type: application/json'); if (!empty($this->pretty_print)) { echo json_encode($this->data, $this->pretty_print); } else { echo json_encode($this->data); } break; default: // Allow other formats to be added via extensions do_action('give_api_output_' . $format, $this->data, $this); break; } do_action('give_api_output_after', $this->data, $this, $format); give_die(); }
/** * @param array $data * @return bool|string */ public function generatePackage($data = array()) { $project_info = $this->getProjectConfig($this->session->data['dev_tools_prj_id']); $extension = $project_info['extension_txt_id']; if (!$extension) { return false; } if (!is_dir(DIR_EXT . $extension)) { return false; } $config_xml = simplexml_load_file(DIR_EXT . $extension . '/config.xml'); $data['version'] = (string) $config_xml->version; foreach ($config_xml->cartversions->item as $store_version) { $data['cartversions'][] = (string) $store_version; } if (is_writable(DIR_APP_SECTION . 'system/temp') && file_exists(DIR_APP_SECTION . 'system/temp')) { $package_dir = DIR_APP_SECTION . 'system/temp/'; } elseif (!is_dir(DIR_APP_SECTION . 'system/temp')) { $result = mkdir(DIR_APP_SECTION . 'system/temp', 0777); if (!$result) { $package_dir = sys_get_temp_dir(); } else { $package_dir = DIR_APP_SECTION . 'system/temp/'; } } else { $package_dir = sys_get_temp_dir(); } if (file_exists($package_dir . $extension)) { // if stuck files exists - breaks return false; } $package_directory = $package_dir . $extension . '_' . $data['version'] . '/'; mkdir($package_directory, 0777); mkdir($package_directory . '/code', 0777); mkdir($package_directory . '/code/extensions', 0777); mkdir($package_directory . '/code/extensions/' . $extension, 0777); $this->_copyDir(DIR_EXT . $extension, $package_directory . '/code/extensions/' . $extension); // build package.xml $xml_data = array('id' => $extension, 'type' => 'extension', 'version' => $data['version'], 'minversion' => $data['version']); if ($data['cartversions']) { foreach ($data['cartversions'] as &$ver) { $ver = explode('.', $ver); $ver = $ver[0] . "." . $ver[1]; } unset($ver); $xml_data['cartversions'] = array('item' => $data['cartversions']); } $xml_data['package_content'] = array('extensions' => array('extension' => $extension)); $xml = Array2XML::createXML('package', $xml_data); $xml = $xml->saveXML(); file_put_contents($package_directory . 'package.xml', $xml); if ($data['license']) { file_put_contents($package_directory . 'license.txt', $data['license']); } if ($data['copyright']) { file_put_contents($package_directory . 'copyright.txt', $data['copyright']); } $archive = new ABackup($extension . '_' . $data['version']); $archive->archive($package_dir . $extension . '_' . $data['version'] . '.tar.gz', $package_dir, $extension . '_' . $data['version']); if (file_exists($package_dir . $extension . '_' . $data['version'] . '.tar.gz')) { return $package_dir . $extension . '_' . $data['version'] . '.tar.gz'; } else { return false; } }
function json2xml($obj_datas, $type = false, $account = false) { switch ($type) { case 'usrkeys': // write keysettings to expansions module $expm = explode("-", $obj_datas['prov'][0]['provision']['endpoint_model']); $module = '0'; foreach ($obj_datas['prov'][0]['provision']['feature_keys'] as $key => $kind) { /* we support 1 or 2 expansions modules */ if ($expm[1] == 2 && $key > 36) { $keydiff = -36; $module = 1; } $xml_keys .= write_xml_keys($kind, $module, $key - $keydiff, $obj_datas, $account); } return "<functionKeys>\n" . $xml_keys . "</functionKeys>\n"; break; case 'usrpbook': // write keysettings to expansions module $expm = explode("-", $obj_datas['prov'][0]['provision']['endpoint_model']); if ($expm[1] == true) { $module = '0'; foreach ($obj_datas['prov'][0]['provision']['feature_keys'] as $key => $kind) { /* we support 1 or 2 expansions modules */ if ($expm[1] == 2 && $key > 36) { $keydiff = -36; $module = 1; } $xml_pbook .= write_xml_keys($kind, $module, $key - $keydiff, $obj_datas); } } return "<tbook e=\"2\">\n" . $xml_pbook . "</tbook>\n" . '</settings>' . "\n"; break; case 'settings': $array = json_decode(json_encode($obj_datas), true); //$array = XML2Array::createArray($xml); $xml = Array2XML::createXML('settings', $array); $str = $xml->saveXML($xml->documentElement); $str = substr($str, strpos($str, "\n") + 1); $str = substr($str, 0, strrpos($str, "\n")); //echo $str; //exit; return $str . "\n"; break; } }
/** * Method buildCCD() */ public function createCCD() { try { if (!isset($this->pid)) { throw new Exception('PID variable not set'); } $this->xmlData = ['@attributes' => ['xmlns' => 'urn:hl7-org:v3', 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', 'xsi:schemaLocation' => 'urn:hl7-org:v3 CDA.xsd']]; if (isset($this->eid)) { $this->encounter = $this->Encounter->getEncounter((int) $this->eid, false, false); $this->encounter = isset($this->encounter['encounter']) ? $this->encounter['encounter'] : $this->encounter; $this->encounterProvider = $this->User->getUserByUid($this->encounter['provider_uid']); $this->encounterFacility = $this->Facilities->getFacility($this->encounter['facility']); } $this->setRequirements(); $this->setHeader(); /** * Array of sections to include in CCD */ $sections = ['ReasonOfVisit', 'Instructions', 'ReasonForReferral', 'Procedures', 'Vitals', 'Immunizations', 'Medications', 'MedicationsAdministered', 'PlanOfCare', 'CareOfPlan', 'Problems', 'Allergies', 'SocialHistory', 'Results', 'FunctionalStatus']; /** * Run Section method for each section */ foreach ($sections as $Section) { call_user_func([$this, "set{$Section}Section"]); } /** * Build the CCR XML Object */ Array2XML::init('1.0', 'UTF-8', true, ['xml-stylesheet' => 'type="text/xsl" href="' . URL . '/lib/CCRCDA/schema/cda2.xsl"']); $this->xml = Array2XML::createXML('ClinicalDocument', $this->xmlData); } catch (Exception $e) { print $e->getMessage(); } }
function getXMLDocument() { try { $filePointer = "../reports/{$this->reportDir}/reportStatement.sql"; if (file_exists($filePointer) && is_readable($filePointer)) { // Important connection parameter, this will allow multiple // prepare tags with the same name. $this->conn = Matcha::getConn(); $this->conn->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); // Get the report SQL statement content $fileContent = file_get_contents($filePointer); // Copy all the request variables into the Prepared Values, // also check if it came from the grid form and normal form. // This because we need to do a POST-PREPARE the SQL statement foreach ($this->request as $field) { $PrepareField[':' . $field['name']]['operator'] = isset($field['operator']) ? $field['operator'] : '='; $PrepareField[':' . $field['name']]['value'] = $field['value']; } // Copy all the request filter variables to the XML, // also check if it came from the grid form and normal form. // This because we need to do a POST-PREPARE the SQL statement foreach ($this->request as $field) { $ReturnFilter[$field['name']]['operator'] = isset($field['operator']) ? $field['operator'] : '='; $ReturnFilter[$field['name']]['value'] = $field['value']; } // Prepare all the variable fields in the SQL Statement $PreparedSQL = $this->PostPrepare($fileContent, $PrepareField); $Queries = explode(';', $PreparedSQL); // Run all the SQL Statement separated by `;` in the file foreach ($Queries as $Query) { if (strlen(trim($Query)) > 0) { $SQL = $this->conn->prepare($Query); $SQL->execute(); $records[] = $SQL->fetchAll(PDO::FETCH_ASSOC); } } $ExtraAttributes['xml-stylesheet'] = 'type="text/xsl" href="report.xsl"'; Array2XML::init('1.0', 'UTF-8', true, $ExtraAttributes); $xml = Array2XML::createXML('records', array('filters' => $ReturnFilter, 'record' => $records[count($records) - 1])); return $xml->saveXML(); } else { throw new Exception('Error: Not SQL Statement file was found or readable.'); } } catch (Exception $Error) { error_log(print_r($Error, true)); return $Error; } }
foreach ($campos as $x => $val) { $nodo[$val] = $_POST[$val][$i]; if (!$nodo[$val] || empty($nodo[$val])) { $errores[] = "No value for " . $val . " " . $i; } } $nodo["@attributes"] = array("id" => $_POST['id'][$i]); $TelevisionArrForm[] = $nodo; //krumo($nodo); } //krumo($TelevisionArrForm); $Television = array("Televisions" => array("Television" => $TelevisionArrForm, "@attributes" => array("noNamespaceSchemaLocation" => "Televisions.xsd"))); //krumo($Televisions); if (empty($errores)) { $Array2XML = Array2XML::init('1.0', 'iso-8859-1'); $outputDestXML = Array2XML::createXML('Televisions', $Television); $xmlString = $outputDestXML->saveXML(); $xmlString = utf8_encode($xmlString); $xmlDestinoFile = $_SESSION['workfolder_webdir'] . "Television.xml"; $fp = fopen($xmlDestinoFile, 'w'); fwrite($fp, $xmlString); fclose($fp); } else { $message = "<h3>Errores al parsear </h3>" . implode("<br>", $errores); } } /*$xml = simplexml_load_file($xmlDestino, 'SimpleXMLElement',LIBXML_NOCDATA); $json = json_encode($xml); $XMLarray = json_decode($json,TRUE); krumo($XMLarray);*/ $xml = @file_get_contents($xmlDestino);