本文整理汇总了PHP中XML_Unserializer::unserialize方法的典型用法代码示例。如果您正苦于以下问题:PHP XML_Unserializer::unserialize方法的具体用法?PHP XML_Unserializer::unserialize怎么用?PHP XML_Unserializer::unserialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XML_Unserializer
的用法示例。
在下文中一共展示了XML_Unserializer::unserialize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testFloat
/**
* Test unserializing a float
*/
public function testFloat()
{
$u = new XML_Unserializer();
$u->setOption(XML_UNSERIALIZER_OPTION_GUESS_TYPES, true);
$xml = '<xml>453.54553</xml>';
$u->unserialize($xml);
$this->assertEquals(453.54553, $u->getUnserializedData());
$xml = '<xml>-1.47</xml>';
$u->unserialize($xml);
$this->assertEquals(-1.47, $u->getUnserializedData());
}
示例2: read
protected function read($filename)
{
$xml = file_get_contents($filename);
$unserializer = new XML_Unserializer();
$unserializer->unserialize($xml);
return $unserializer->getUnserializedData();
}
示例3: gmlConverter
function __construct($gmlSource)
{
parent::__construct();
include_once "libs/class_xml_check.php";
$check = new XML_check();
if ($check->check_string($gmlSource)) {
print "GML is well-formed\n";
//print("Elements : ".$check->get_xml_elements());
//print("Attributes : ".$check->get_xml_attributes());
//print("Size : ".$check->get_xml_size());
//print("Text sections : ".$check->get_xml_text_sections());
//print("Text size : ".$check->get_xml_text_size());
} else {
print "GML is not well-formed. ";
print $check->get_full_error() . "\n";
print "Script terminated\n";
die;
}
$this->gmlSource = $gmlSource;
$this->gmlCon = new gmlConverter();
require_once "XML/Unserializer.php";
$unserializer_options = array('parseAttributes' => TRUE);
$unserializer = new XML_Unserializer($unserializer_options);
// Serialize the data structure
$status = $unserializer->unserialize($this->gmlSource);
$this->gmlArray = $unserializer->getUnserializedData();
print date('l jS \\of F Y h:i:s A') . " GML serialized\n";
// Check if XML is a ServiceException
if ($unserializer->getRootName() == "ServiceExceptionReport") {
print "The server returned an exception:\n";
print $this->gmlSource . "\n";
print "Script terminated\n";
die;
}
}
示例4: testRootName
/**
* Test extracting the root name
*/
public function testRootName()
{
$u = new XML_Unserializer();
$xml = '<xml>data</xml>';
$u->unserialize($xml);
$this->assertEquals('xml', $u->getRootName());
}
示例5: _loadAcronymList
function _loadAcronymList()
{
$unser = new XML_Unserializer(array('parseAttributes' => TRUE, 'attributesArray' => '_attrs'));
$unser->unserialize(PATH_INCLUDE . "xslt/inc/acronyms.xml", true);
$dat = $unser->getUnserializedData();
return $dat['word'];
}
示例6: fetchData
function fetchData($username, $password)
{
switch ($this->options['cryptType']) {
case 'blowfish':
include_once 'Crypt/Blowfish.php';
$bf = new Crypt_Blowfish($this->options['cryptKey']);
$password = $bf->encrypt($password);
$password = base64_encode($password);
break;
default:
if (function_exists($this->options['cryptType'])) {
$password = $this->options['cryptType']($password);
}
break;
}
$req = new HTTP_Request();
$req->setURL($this->options['URL']);
$req->setMethod(HTTP_REQUEST_METHOD_GET);
$req->addQueryString($this->options['usernameKey'], $username);
$req->addQueryString($this->options['passwordKey'], $password);
if (!PEAR::isError($req->sendRequest())) {
$response = $req->getResponseBody();
} else {
return false;
}
$unserializer = new XML_Unserializer();
if ($unserializer->unserialize($response)) {
$this->result_value = $unserializer->getUnserializedData();
if ($this->result_value[$this->options['resultKey']] == $this->options['correctValue']) {
return true;
}
}
return false;
}
示例7: testIndexed
/**
* Test unserializing an indexed array
*/
public function testIndexed()
{
$u = new XML_Unserializer();
$u->setOption(XML_UNSERIALIZER_OPTION_COMPLEXTYPE, 'array');
$xml = '<xml><foo>bar</foo><foo>tomato</foo></xml>';
$u->unserialize($xml);
$this->assertEquals(array('foo' => array('bar', 'tomato')), $u->getUnserializedData());
}
示例8: readData
function readData()
{
require_once 'XML/Unserializer.php';
$xmlEngine = new XML_Unserializer();
if ($xmlEngine->unserialize($this->getFile())) {
return $xmlEngine->getUnserializedData();
}
return false;
}
示例9: testUtf8ToIso
/**
* Test unserializing from UTF-8 to ISO-8859-1
*/
public function testUtf8ToIso()
{
$u = new XML_Unserializer();
$u->setOption(XML_UNSERIALIZER_OPTION_ENCODING_SOURCE, 'UTF-8');
$u->setOption(XML_UNSERIALIZER_OPTION_ENCODING_TARGET, 'ISO-8859-1');
$xml = '<xml>' . utf8_encode('A string containing ü ä Ãê') . '</xml>';
$u->unserialize($xml);
$this->assertEquals('A string containing ü ä Ãê', $u->getUnserializedData());
}
示例10: executeIndex
/**
* Executes index action
*
* @param sfRequest $request A request object
*/
public function executeIndex(sfWebRequest $request)
{
$b = new sfWebBrowser();
$b->post(sfConfig::get('sf_takutomo_get_reserved_driver_url'), array('guid' => 'mixi,' . MixiAppMobileApi::$ownerId));
$options = array('complexType' => 'array', 'parseAttributes' => TRUE);
$Unserializer = new XML_Unserializer($options);
//$Unserializer->setOption('parseAttributes', TRUE);
$status = $Unserializer->unserialize($b->getResponseText());
$this->list = $Unserializer->getUnserializedData();
}
示例11: executeIndex
/**
* Executes index action
*
* @param sfRequest $request A request object
*/
public function executeIndex(sfWebRequest $request)
{
$this->form = new sfForm();
//xmlを連想配列に変換
$options = array('complexType' => 'array');
$b = new sfWebBrowser();
$b->post(sfConfig::get('sf_takutomo_get_profile_url'), array('id' => $this->getRequestParameter('m_id')));
$Unserializer = new XML_Unserializer($options);
$status = $Unserializer->unserialize($b->getResponseText());
$this->profile = $Unserializer->getUnserializedData();
}
示例12: doUnpack
/**
* Unpack definition procedure
*
* @return array
* @author Sergey Startsev
*/
protected function doUnpack($definition)
{
$unserializer = new XML_Unserializer($this->unserialize_options);
// check unserialize status
$status = $unserializer->unserialize(trim($definition), false);
if (!$status) {
throw new afsXmlDefinitionException($status->getMessage());
}
// get unserialized data
return $unserializer->getUnserializedData();
}
示例13: testSetterMethod
/**
* Test unserializing with a setter method
*/
public function testSetterMethod()
{
$u = new XML_Unserializer();
$u->setOption(XML_UNSERIALIZER_OPTION_COMPLEXTYPE, 'object');
$u->setOption(XML_UNSERIALIZER_OPTION_DEFAULT_CLASS, 'Foo');
$xml = '<SetterExample><foo>tomato</foo></SetterExample>';
$u->unserialize($xml);
$result = new SetterExample();
$result->setFoo('tomato');
$this->assertEquals($result, $u->getUnserializedData());
}
示例14: executeIndex
/**
* Executes index action
*
* @param sfRequest $request A request object
*/
public function executeIndex(sfWebRequest $request)
{
$b = new sfWebBrowser();
$b->get(sfConfig::get('sf_takutomo_get_attend_event_url'), array('guid' => 'DEBUG,sample_member_001'));
//xmlを連想配列に変換
$options = array('complexType' => 'array');
$Unserializer = new XML_Unserializer($options);
$status = $Unserializer->unserialize($b->getResponseText());
//if ($status === true) {
$this->get_attend_event_list = $Unserializer->getUnserializedData();
}
示例15: randomPerson
function randomPerson()
{
$dir = 'collectedData';
$files = glob($dir . '/*.*');
$file = array_rand($files);
$us = new XML_Unserializer();
$options = array(XML_UNSERIALIZER_OPTION_TAG_MAP => array('util' => 'XML_Util'), XML_UNSERIALIZER_OPTION_ATTRIBUTE_CLASS => '_classname');
$us->setOptions($options);
$us->setOption(XML_UNSERIALIZER_OPTION_COMPLEXTYPE, 'object');
$result = $us->unserialize($files[$file], true);
return $us->_unserializedData;
}