当前位置: 首页>>代码示例>>PHP>>正文


PHP XML_Serializer::setOption方法代码示例

本文整理汇总了PHP中XML_Serializer::setOption方法的典型用法代码示例。如果您正苦于以下问题:PHP XML_Serializer::setOption方法的具体用法?PHP XML_Serializer::setOption怎么用?PHP XML_Serializer::setOption使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在XML_Serializer的用法示例。


在下文中一共展示了XML_Serializer::setOption方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testEncoding

 /**
  * Add encoding
  */
 public function testEncoding()
 {
     $s = new XML_Serializer($this->options);
     $s->setOption(XML_SERIALIZER_OPTION_XML_DECL_ENABLED, true);
     $s->setOption(XML_SERIALIZER_OPTION_XML_ENCODING, 'ISO-8859-1');
     $s->serialize('string');
     $this->assertEquals('<?xml version="1.0" encoding="ISO-8859-1"?><string>string</string>', $s->getSerializedData());
 }
开发者ID:quangbt2005,项目名称:vhost-kis,代码行数:11,代码来源:Serializer_Option_XmlDeclaration_TestCase.php

示例2: testNumberedObjects

 /**
  * Test object
  */
 public function testNumberedObjects()
 {
     $s = new XML_Serializer($this->options);
     $s->setOption(XML_SERIALIZER_OPTION_CLASSNAME_AS_TAGNAME, true);
     $s->setOption(XML_SERIALIZER_OPTION_TAGMAP, array('stdClass' => 'foo'));
     $s->serialize(array(new stdClass(), new stdClass()));
     $this->assertEquals('<array><foo /><foo /></array>', strtolower($s->getSerializedData()));
 }
开发者ID:quangbt2005,项目名称:vhost-kis,代码行数:11,代码来源:Serializer_Option_TagMap_TestCase.php

示例3: testId

 /**
  * Declaration and ID and system reference
  */
 public function testId()
 {
     $s = new XML_Serializer($this->options);
     $s->setOption(XML_SERIALIZER_OPTION_DOCTYPE_ENABLED, true);
     $s->setOption(XML_SERIALIZER_OPTION_DOCTYPE, array('uri' => 'http://pear.php.net/dtd/package-1.0', 'id' => '-//PHP//PEAR/DTD PACKAGE 1.0'));
     $s->serialize('string');
     $this->assertEquals('<!DOCTYPE string PUBLIC "-//PHP//PEAR/DTD PACKAGE 1.0" "http://pear.php.net/dtd/package-1.0"><string>string</string>', $s->getSerializedData());
 }
开发者ID:quangbt2005,项目名称:vhost-kis,代码行数:11,代码来源:Serializer_Option_DocType_TestCase.php

示例4: testUri

 /**
  * Simple namespace
  */
 public function testUri()
 {
     $s = new XML_Serializer($this->options);
     $s->setOption(XML_SERIALIZER_OPTION_NAMESPACE, array('foo', 'http://pear.php.net/XML_Serializer/foo'));
     $s->serialize(array('foo' => 'bar'));
     $this->assertEquals('<foo:array xmlns:foo="http://pear.php.net/XML_Serializer/foo"><foo:foo>bar</foo:foo></foo:array>', $s->getSerializedData());
 }
开发者ID:pear,项目名称:xml_serializer,代码行数:10,代码来源:Serializer_Option_NamespaceTest.php

示例5: testSimpleXML

 /**
  * SimpleXML
  */
 public function testSimpleXML()
 {
     $s = new XML_Serializer($this->options);
     $s->setOption(XML_SERIALIZER_OPTION_MODE, XML_SERIALIZER_MODE_SIMPLEXML);
     $s->serialize(array('foo' => array(1, 2, 3), 'bar' => array(1, 2, 3)));
     $this->assertEquals('<array><foo>1</foo><foo>2</foo><foo>3</foo><bar>1</bar><bar>2</bar><bar>3</bar></array>', $s->getSerializedData());
 }
开发者ID:pear,项目名称:xml_serializer,代码行数:10,代码来源:Serializer_Option_ModeTest.php

示例6: testMixed

 /**
  * Test setting mixed default tags
  */
 public function testMixed()
 {
     $s = new XML_Serializer($this->options);
     $data = array('foos' => array(1, 2), 'bars' => array(1, 2), 'test');
     $s->setOption(XML_SERIALIZER_OPTION_DEFAULT_TAG, array('foos' => 'foo', '#default' => 'tag'));
     $s->serialize($data);
     $this->assertEquals('<array><foos><foo>1</foo><foo>2</foo></foos><bars><tag>1</tag><tag>2</tag></bars><tag>test</tag></array>', $s->getSerializedData());
 }
开发者ID:pear,项目名称:xml_serializer,代码行数:11,代码来源:Serializer_Option_DefaultTagTest.php

示例7: testTabs

    /**
     * Indent with tabs
     */
    public function testTabs()
    {
        $s = new XML_Serializer($this->options);
        $s->setOption(XML_SERIALIZER_OPTION_INDENT, "\t");
        $s->serialize(array('foo' => 'bar'));
        $this->assertEquals('<array>
	<foo>bar</foo>
</array>', $s->getSerializedData());
    }
开发者ID:quangbt2005,项目名称:vhost-kis,代码行数:12,代码来源:Serializer_Option_Indent_TestCase.php

示例8: array

 function ws_model_id($request, $model = false, $id = false)
 {
     $resArr = array();
     if (class_exists($model)) {
         if ($request->_request_method == HttpRequest::REQUEST_METHOD_GET) {
             $obj = Doctrine::getTable($model)->find($id);
             if ($obj) {
                 $resArr['data'] = $obj->toArray();
             }
         } elseif ($request->_request_method == HttpRequest::REQUEST_METHOD_POST) {
             $obj = Doctrine::getTable($model)->find($id);
             if (!$obj) {
                 $obj = new $model();
             }
             try {
                 $obj->fromArray($request->_request_data);
                 $obj->save();
                 $resArr['data'] = $obj->toArray();
                 $resArr['code'] = "200";
                 $resArr['message'] = "OK";
             } catch (Exception $e) {
                 $resArr['code'] = "304";
                 $resArr['error']['message'] = "Not Modified";
             }
         } else {
             $resArr['code'] = "400";
             $resArr['message'] = "Bad Request";
             $resArr['error']['message'] = "Bad Request";
         }
     } else {
         $resArr['code'] = "404";
         $resArr['message'] = "Not Found";
         $resArr['error']['message'] = $model . ' Not Found';
     }
     header('Cache-Control: no-cache, must-revalidate');
     header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
     header("Content-type: text/xml; charset=utf-8");
     if ($request->is_ajax()) {
         echo json_encode($resArr);
     } else {
         require_once 'XML/Serializer.php';
         $serializer = new XML_Serializer();
         $serializer->setOption(XML_SERIALIZER_OPTION_INDENT, '    ');
         $serializer->setOption(XML_SERIALIZER_OPTION_ROOT_NAME, 'RestWS');
         $serializer->setOption(XML_SERIALIZER_OPTION_XML_ENCODING, 'UTF-8');
         $serializer->setOption(XML_SERIALIZER_OPTION_LINEBREAKS, "\n");
         $serializer->setOption(XML_SERIALIZER_OPTION_DEFAULT_TAG, 'item');
         $serializer->setOption(XML_SERIALIZER_OPTION_CDATA_SECTIONS, FALSE);
         $result = $serializer->serialize($resArr);
         $xml = $serializer->getSerializedData();
         echo $xml;
     }
 }
开发者ID:hbasria,项目名称:pjango,代码行数:53,代码来源:Views.php

示例9: array

$options = array("indent" => '    ', "linebreak" => "\n");
$serializer = new XML_Serializer($options);
$object = new stdClass();
$object->foo = 'bar';
$object->bar = null;
$array = array('foo' => 'bar', 'bar' => null);
$result = $serializer->serialize($object);
if ($result === true) {
    echo "<pre>";
    echo htmlentities($serializer->getSerializedData());
    echo "</pre>";
}
$result = $serializer->serialize($array);
if ($result === true) {
    echo "<pre>";
    echo htmlentities($serializer->getSerializedData());
    echo "</pre>";
}
$serializer->setOption('ignoreNull', true);
$result = $serializer->serialize($object);
if ($result === true) {
    echo "<pre>";
    echo htmlentities($serializer->getSerializedData());
    echo "</pre>";
}
$result = $serializer->serialize($array);
if ($result === true) {
    echo "<pre>";
    echo htmlentities($serializer->getSerializedData());
    echo "</pre>";
}
开发者ID:prometheus-ev,项目名称:promdilps,代码行数:31,代码来源:serializeNullProperties.php

示例10: array

<?php

/**
 * XML Serializer example
 *
 * This example makes use of the CData sections option
 *
 * @author  Stephan Schmidt <schst@php.net>
 */
error_reporting(E_ALL);
require_once 'XML/Serializer.php';
$serializer = new XML_Serializer();
$serializer->setOption(XML_SERIALIZER_OPTION_INDENT, '    ');
$serializer->setOption(XML_SERIALIZER_OPTION_DEFAULT_TAG, 'item');
$serializer->setOption(XML_SERIALIZER_OPTION_CDATA_SECTIONS, true);
$data = array('foo' => 'This is some text...', 'bar' => '& even more text...', 'test' => array('Foo', 'Foo & bar'));
$result = $serializer->serialize($data);
if ($result === true) {
    $xml = $serializer->getSerializedData();
    echo '<pre>';
    echo htmlspecialchars($xml);
    echo '</pre>';
} else {
    $result->getMessage();
    exit;
}
开发者ID:BackupTheBerlios,项目名称:dilps,代码行数:26,代码来源:serializeCData.php

示例11: htmlspecialchars

<?php

/**
 * This shows that XML_Serializer is able to work with
 * empty arrays
 *
 * @author Stephan Schmidt <schst@php.net>
 */
error_reporting(E_ALL);
require_once 'XML/Serializer.php';
$data = array(array('name' => 'Superman', 'age' => 34, 'realname' => 'Clark Kent'), array('name' => 'Batman', 'age' => 32, 'realname' => 'Bruce Wayne'), 'villain' => array('name' => 'Professor Zoom', 'age' => 'unknown', 'realname' => 'Hunter Zolomon'));
$serializer = new XML_Serializer();
$serializer->setOption(XML_SERIALIZER_OPTION_INDENT, '    ');
$serializer->setOption(XML_SERIALIZER_OPTION_DEFAULT_TAG, 'hero');
$serializer->serialize($data);
echo '<pre>';
echo "Default behaviour:\n";
echo htmlspecialchars($serializer->getSerializedData());
echo '</pre>';
$serializer->setOption(XML_SERIALIZER_OPTION_SCALAR_AS_ATTRIBUTES, true);
$serializer->serialize($data);
echo '<pre>';
echo "XML_SERIALIZER_OPTION_SCALAR_AS_ATTRIBUTES = true:\n";
echo htmlspecialchars($serializer->getSerializedData());
echo '</pre>';
$serializer->setOption(XML_SERIALIZER_OPTION_SCALAR_AS_ATTRIBUTES, array('hero' => array('name', 'age'), 'villain' => array('realname')));
$serializer->serialize($data);
echo '<pre>';
echo "XML_SERIALIZER_OPTION_SCALAR_AS_ATTRIBUTES is an array:\n";
echo htmlspecialchars($serializer->getSerializedData());
echo '</pre>';
开发者ID:quangbt2005,项目名称:vhost-kis,代码行数:31,代码来源:serializeSelectiveAttributes.php

示例12: htmlentities

<?php

require_once 'XML/Serializer.php';
$citation = array('book' => array('author' => array(array('John Doe', 'attributes' => array('id' => 1)), array('Bob Jones', 'attributes' => array('id' => 2))), 'title' => 'Title of the book'));
$s = new XML_Serializer();
$s->setOption(XML_SERIALIZER_OPTION_INDENT, '    ');
$s->setOption(XML_SERIALIZER_OPTION_ATTRIBUTES_KEY, 'attributes');
$s->setOption(XML_SERIALIZER_OPTION_MODE, XML_SERIALIZER_MODE_SIMPLEXML);
$s->serialize($citation);
echo '<pre>';
echo htmlentities($s->getSerializedData());
echo '</pre>';
开发者ID:pear,项目名称:xml_serializer,代码行数:12,代码来源:Serializer_Bug7112.php

示例13:

 function time_in_transit()
 {
     $this->service = 'time in transit';
     $serializer = new XML_Serializer();
     $serializer->setOption('linebreak', '');
     $serializer->setOption('addDecl', true);
     $serializer->setOption('rootName', 'TimeInTransitRequest');
     $root_attr['xml:lang'] = 'en-US';
     $serializer->setOption('rootAttributes', $root_attr);
     $customercontext = 'Request generated by PHP PEAR Services_UPS Package by Tim Batz';
     $xml_array['Request']['TransactionReference']['CustomerContext'] = $customercontext;
     $xml_array['Request']['TransactionReference']['XpciVersion'] = '1.0001';
     $xml_array['Request']['RequestAction'] = 'TimeInTransit';
     $xml_array['TransitFrom']['AddressArtifactFormat']['PoliticalDivision3'] = '';
     $xml_array['TransitFrom']['AddressArtifactFormat']['PoliticalDivision2'] = '';
     $xml_array['TransitFrom']['AddressArtifactFormat']['PoliticalDivision1'] = '';
     $xml_array['TransitFrom']['AddressArtifactFormat']['CountryCode'] = '';
     $xml_array['TransitFrom']['AddressArtifactFormat']['PostcodePrimaryLow'] = '';
     $xml_array['TransitTo']['AddressArtifactFormat']['PoliticalDivision3'] = '';
     $xml_array['TransitTo']['AddressArtifactFormat']['PoliticalDivision2'] = '';
     $xml_array['TransitTo']['AddressArtifactFormat']['PoliticalDivision1'] = '';
     $xml_array['TransitTo']['AddressArtifactFormat']['CountryCode'] = '';
     $xml_array['TransitTo']['AddressArtifactFormat']['PostcodePrimaryLow'] = '';
     $xml_array['TransitTo']['AddressArtifactFormat']['ResidentialAddressIndicator'] = '';
     $xml_array['PickupDate'] = '';
     $xml_array['ShipmentWeight']['UnitOfMeasurement']['Code'] = '';
     // LBS/KGS
     $xml_array['ShipmentWeight']['UnitOfMeasurement']['Description'] = '';
     // Pounds/Kilograms
     $xml_array['ShipmentWeight']['Weight'] = '';
     $xml_array['TotalPackagesInShipment'] = '';
     // default 1
     $xml_array['InvoiceLineTotal']['CurrencyCode'] = '';
     $xml_array['InvoiceLineTotal']['MonetaryValue'] = '';
     $xml_array['DocumentsOnlyIndicator'] = '';
     // set or not
     $xml_array['MaximumListSize'] = '';
     // default 35 / 1-50
     /*
     $msg  = 'At least one parameter is needed validate an address!';
     PEAR::raiseError($msg, 0, PEAR_ERROR_DIE);
     */
     $serializer->serialize($xml_array);
     $this->request = $serializer->getSerializedData();
 }
开发者ID:alachaum,项目名称:timetrex,代码行数:45,代码来源:UPS.php

示例14:

    $_POST['cmb_clib_version'] = '';
}
$libc_version = $_POST['cmb_clib_version'];
$config->set_target_options($_POST['cmb_arch'], $_POST['cmb_variant'], $_POST['rd_abi'], $_POST['cmb_endian'], $_POST['cmb_float']);
$config->set_toolchain_options($_POST['chk_sysroot'], $_POST['chk_build_shared_lib'], 'unknown');
$config->set_os($_POST['cmb_os'], $_POST['cmb_kernel_version']);
$config->set_gmp_mpfr($_POST['chk_gmp_mpfr'], $_POST['cmb_gmp'], $_POST['cmb_mpfr']);
$config->set_binutils($_POST['cmb_binutils'], $_POST['chk_libbfd'], $_POST['chk_libiberty']);
$config->set_cc($_POST['cmb_cc'], $_POST['chk_cpp'], $_POST['chk_fortran'], $_POST['chk_java']);
$config->set_clib($_POST['cmb_clib'], $libc_version, $_POST['cmb_thread']);
$config->set_tools($_POST['chk_libelf'], $_POST['chk_sstrip']);
$config->set_debug($_POST['chk_gdb'], $_POST['chk_dmalloc'], $_POST['chk_duma'], $_POST['chk_ltrace'], $_POST['chk_strace']);
// add XML declaration
//$serializer->setOption("addDecl", true);
// indent elements
$serializer->setOption("indent", "    ");
// set name for root element
$serializer->setOption("rootName", "ToolchainConfig");
$serializer->setOption("classAsTagName", "true");
$serializer->serialize($config);
//print $serializer->getSerializedData();
// Giving the toolchain configuration file name
$manufacturer = 'unknown';
$arch = $_POST['cmb_arch'];
$variant = $_POST['cmb_variant'];
$endianness = $_POST['cmb_endian'];
$abi = $_POST['rd_abi'];
$libc = $_POST['cmb_clib'];
/////////////////////////////////////////////////////////////////////
// The architecture part of the toolchain tuple
if ($arch == 'x86') {
开发者ID:hichem,项目名称:emblinux_website,代码行数:31,代码来源:build_toolchain.php

示例15:

require_once "Connections/freedomrising.php";
require_once "XML/Serializer.php";
$dbcon->SetFetchMode(ADODB_FETCH_ASSOC);
$user_sql = "SELECT * FROM phplist_user_user";
$attribute_sql = "SELECT * FROM phplist_user_user_attribute LEFT JOIN phplist_user_attribute ON phplist_user_user_attribute.attributeid = phplist_user_attribute.id";
$list_sql = "SELECT * FROM phplist_listuser";
$user_rs = $dbcon->Execute($user_sql);
$attr_rs = $dbcon->Execute($attribute_sql);
$list_rs = $dbcon->Execute($list_sql);
while ($row = $user_rs->FetchRow()) {
    $subdata[$row['id']] = $row;
}
while ($row = $attr_rs->FetchRow()) {
    $attrname = str_replace(" ", "_", $row['name']);
    $subdata[$row['userid']][$attrname] = $row['value'];
}
while ($row = $list_rs->FetchRow()) {
    $subdata[$row['userid']]['list'][] = $row['listid'];
}
$serializer = new XML_Serializer();
$serializer->setOption("addDecl", true);
$serializer->setOption("indent", "    ");
$serializer->setOption("rootName", "user");
//$serializer->setOption( "defaultTagName", "user" );
$serializer->setOption("mode", "simplexml");
$result = $serializer->serialize($subdata);
header('Content-Type: text/xml');
if ($result === true) {
    $xmlout = $serializer->getSerializedData();
}
print $xmlout;
开发者ID:radicalsuz,项目名称:amp,代码行数:31,代码来源:export_phplist.php


注:本文中的XML_Serializer::setOption方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。