本文整理汇总了PHP中XML_Unserializer类的典型用法代码示例。如果您正苦于以下问题:PHP XML_Unserializer类的具体用法?PHP XML_Unserializer怎么用?PHP XML_Unserializer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了XML_Unserializer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
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;
}
}
示例2: 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;
}
示例3: 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());
}
示例4: _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'];
}
示例5: read
protected function read($filename)
{
$xml = file_get_contents($filename);
$unserializer = new XML_Unserializer();
$unserializer->unserialize($xml);
return $unserializer->getUnserializedData();
}
示例6: 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());
}
示例7: readData
function readData()
{
require_once 'XML/Unserializer.php';
$xmlEngine = new XML_Unserializer();
if ($xmlEngine->unserialize($this->getFile())) {
return $xmlEngine->getUnserializedData();
}
return false;
}
示例8: 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());
}
示例9: 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();
}
示例10: 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();
}
示例11: 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();
}
示例12: 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());
}
示例13: 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();
}
示例14: setEventDetail
private function setEventDetail()
{
$b = new sfWebBrowser();
$b->post(sfConfig::get('sf_takutomo_get_event_detail_url'), array('event_id' => $this->getRequestParameter('event_id')));
if ((int) $xml->status->code >= 1000) {
$this->form->getErrorSchema()->addError(new sfValidatorError(new sfValidatorPass(), (string) $xml->status->description));
} else {
$Unserializer = new XML_Unserializer($this->options);
$status = $Unserializer->unserialize($b->getResponseText());
$this->event_detail = $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;
}