本文整理汇总了PHP中Array2XML::createXML方法的典型用法代码示例。如果您正苦于以下问题:PHP Array2XML::createXML方法的具体用法?PHP Array2XML::createXML怎么用?PHP Array2XML::createXML使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Array2XML
的用法示例。
在下文中一共展示了Array2XML::createXML方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: saveXml
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;
}
}
示例2: get_quota_data
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;
}
示例3: generateOutput
/**
* 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;
}
示例4: optOut
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;
}
示例5: actionSample
/**
* 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();
}
示例6: prepareData
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);
}
示例7: setDocument
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;
}
}
}
示例8: saveconfigAction
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("*/*/"));
}
示例9: array2xml
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();
}
示例10: respond
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;
}
示例11: foreach
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);
示例12: proccessOutput
/**
* 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();
}
示例13: file_get_contents
#!/usr/bin/php
<?php
include "array2xml.php";
include "xml2array.php";
$xml = file_get_contents("../test.xml");
$array = XML2Array::createArray($xml);
#print_r($array);
$php_array = $array;
$xml = Array2XML::createXML('root_node_name', $php_array);
echo $xml->saveXML();
示例14: output
/**
* 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();
}
示例15: createXmlApiCall
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);
}