本文整理汇总了PHP中XML_Unserializer::getRootName方法的典型用法代码示例。如果您正苦于以下问题:PHP XML_Unserializer::getRootName方法的具体用法?PHP XML_Unserializer::getRootName怎么用?PHP XML_Unserializer::getRootName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XML_Unserializer
的用法示例。
在下文中一共展示了XML_Unserializer::getRootName方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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());
}
示例2: 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;
}
}
示例3: ProcessXmlData
/**
* The ProcessXmlData function creates a DOM object representation of the
* XML document received from Google Checkout. It then evaluates the root
* tag of the document to determine which function should handle the document.
*
* This function routes the XML responses that Google Checkout sends in
* response to API requests. These replies are sent to one of the other
* functions in this library.
*
* This function also routes Merchant Calculations API requests and
* Notification API requests. Those requests are processed by functions
* in the MerchantCalculationsAPIFunctions.php and
* NotificationAPIFunctions.php libraries, respectively.
*
* @param $xml_data The XML document sent by the Google Checkout server.
*/
function ProcessXmlData($xml_response)
{
$unserializer = new XML_Unserializer();
$rslt = $unserializer->unserialize($xml_response);
$dom_data_root = $unserializer->getUnserializedData();
$message_recognizer = $unserializer->getRootName();
$sn = '';
if (preg_match('/serial-number="([\\d\\-]+)">/i', $xml_response, $matches)) {
$sn = $matches[1];
}
//$this->LogMessage ("Google Checkout: ProcessXmlData: " . "<br />" . nl2br(htmlspecialchars($xml_response)), $debug_only_msg = true);
$this->LogMessage("Google Checkout: ProcessXmlData: " . "\n" . $xml_response, $debug_only_msg = true);
/*
* Select the appropriate function to handle the XML document
* by evaluating the root tag of the document. Functions to
* handle the following types of responses are contained in
* this document:
* <request-received>
* <error>
* <diagnosis>
* <checkout-redirect>
*
* This function routes the following types of responses
* to the MerchantCalculationsAPIFunctions.php file:
* <merchant-calculation-callback>
*
* This function routes the following types of responses
* to the NotificationAPIFunctions.php file:
* <new-order-notification>
* <order-state-change-notification>
* <charge-amount-notification>
* <chargeback-amount-notification>
* <refund-amount-notification>
* <risk-information-notification>
*
*/
switch ($message_recognizer) {
// <request-received> received
case "request-received":
$this->ProcessRequestReceivedResponse($dom_data_root, $sn);
break;
// <error> received
// <error> received
case "error":
$this->ProcessErrorResponse($dom_data_root, $sn);
break;
// <diagnosis> received
// <diagnosis> received
case "diagnosis":
$this->ProcessDiagnosisResponse($dom_data_root, $sn);
break;
// <checkout-redirect> received
// <checkout-redirect> received
case "checkout-redirect":
$this->ProcessCheckoutRedirect($dom_data_root, $sn);
break;
/*
* +++ CHANGE ME +++
* The following case is only for partners who are implementing
* the Merchant Calculations API. If you are not implementing
* the Merchant Calculations API, you may ignore this case.
*/
// <merchant-calculation-callback> received
/*
* +++ CHANGE ME +++
* The following case is only for partners who are implementing
* the Merchant Calculations API. If you are not implementing
* the Merchant Calculations API, you may ignore this case.
*/
// <merchant-calculation-callback> received
case "merchant-calculation-callback":
$this->ProcessMerchantCalculationCallback($dom_data_root, $sn);
break;
/*
* +++ CHANGE ME +++
* The following cases are only for partners who are
* implementing the Notification API. If you are not
* implementing the Notification API, you may ignore
* the remaining cases in this function.
*/
// <new-order-notification> received
/*
* +++ CHANGE ME +++
* The following cases are only for partners who are
//.........这里部分代码省略.........
示例4: array
$level = 0;
$depth = 0;
$tables = array();
$fields = array();
$wheres = array();
$limits = array();
$unserializer_options = array('parseAttributes' => TRUE, 'typeHints' => FALSE);
$unserializer = new XML_Unserializer($unserializer_options);
// Post method is used
if ($HTTP_RAW_POST_DATA) {
Log::write($HTTP_RAW_POST_DATA);
$HTTP_RAW_POST_DATA = dropNameSpace($HTTP_RAW_POST_DATA);
//makeExceptionReport($HTTP_RAW_POST_DATA);
$status = $unserializer->unserialize($HTTP_RAW_POST_DATA);
$arr = $unserializer->getUnserializedData();
$request = $unserializer->getRootName();
switch ($request) {
case "GetFeature":
$transaction = false;
if (!is_array($arr['Query'][0])) {
$arr['Query'] = array(0 => $arr['Query']);
}
for ($i = 0; $i < sizeof($arr['Query']); $i++) {
if (!is_array($arr['Query'][$i]['PropertyName'])) {
$arr['Query'][$i]['PropertyName'] = array(0 => $arr['Query'][$i]['PropertyName']);
}
}
$HTTP_FORM_VARS["REQUEST"] = "GetFeature";
foreach ($arr['Query'] as $queries) {
$queries['typeName'] = dropAllNameSpaces($queries['typeName']);
$HTTP_FORM_VARS["TYPENAME"] .= $queries['typeName'] . ",";
示例5: header
function wfs_server()
{
// Manually tested this piece of code in order to check the requests.
// Code based on a similar idea but build in Java
header('Content-Type:text/xml; charset=UTF-8', TRUE);
header('Connection:close', TRUE);
//$userFromUri = "mhoegh"; // for testing
logfile::write($userFromUri . "\n\n");
// We connect to the users db
$postgisdb = $userFromUri;
$srs = $srsFromUri;
$postgisschema = $schemaFromUri;
$postgisObject = new postgis();
//$user = new users($userFromUri);
//$version = new version($user);
$geometryColumnsObj = new GeometryColumns();
function microtime_float()
{
list($utime, $time) = explode(" ", microtime());
return (double) $utime + (double) $time;
}
$startTime = microtime_float();
//ini_set("display_errors", "On");
$thePath = "http://" . $_SERVER['SERVER_NAME'] . $_SERVER['REDIRECT_URL'];
//$thePath= "http://".$_SERVER['SERVER_NAME'].$_SERVER['PHP_SELF'];
$server = "http://" . $_SERVER['SERVER_NAME'];
$BBox = null;
//end added
$currentTable = null;
$currentTag = null;
$gen = array();
$gen[0] = "";
$level = 0;
$depth = 0;
$tables = array();
$fields = array();
$wheres = array();
$limits = array();
logfile::write("\nRequest\n\n");
logfile::write($HTTP_RAW_POST_DATA . "\n\n");
$unserializer_options = array('parseAttributes' => TRUE, 'typeHints' => FALSE);
$unserializer = new XML_Unserializer($unserializer_options);
/*$HTTP_RAW_POST_DATA = '<?xml version="1.0" encoding="utf-8"?><wfs:Transaction service="WFS" version="1.0.0" xmlns="http://www.opengis.net/wfs" xmlns:mrhg="http://twitter/mrhg" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><wfs:Insert idgen="GenerateNew"><mrhg:hej><the_geom><gml:MultiPolygon srsName="urn:x-ogc:def:crs:EPSG:6.9:4326"><gml:polygonMember><gml:Polygon><gml:exterior><gml:LinearRing><gml:coordinates>5.0657329559,-41.1107215881 8.4824724197,-39.3435783386 4.3241734505,-34.6001853943 5.0657329559,-41.1107215881 </gml:coordinates></gml:LinearRing></gml:exterior></gml:Polygon></gml:polygonMember></gml:MultiPolygon></the_geom></mrhg:hej></wfs:Insert></wfs:Transaction>';*/
/*$HTTP_RAW_POST_DATA = '<?xml version="1.0"?><DescribeFeatureType version="1.1.0" service="WFS" xmlns="http://www.opengis.net/wfs" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd"> <TypeName>california_coastline</TypeName></DescribeFeatureType>';
*/
// Post method is used
if ($HTTP_RAW_POST_DATA) {
//$forUseInSpatialFilter = $HTTP_RAW_POST_DATA; // We store a unaltered version of the raw request
$HTTP_RAW_POST_DATA = dropNameSpace($HTTP_RAW_POST_DATA);
logfile::write($HTTP_RAW_POST_DATA . "\n\n");
$status = $unserializer->unserialize($HTTP_RAW_POST_DATA);
$arr = $unserializer->getUnserializedData();
$request = $unserializer->getRootName();
//print_r($arr);
switch ($request) {
case "GetFeature":
if (!is_array($arr['Query'][0])) {
$arr['Query'] = array(0 => $arr['Query']);
}
for ($i = 0; $i < sizeof($arr['Query']); $i++) {
if (!is_array($arr['Query'][$i]['PropertyName'])) {
$arr['Query'][$i]['PropertyName'] = array(0 => $arr['Query'][$i]['PropertyName']);
}
}
$HTTP_FORM_VARS["REQUEST"] = "GetFeature";
foreach ($arr['Query'] as $queries) {
$HTTP_FORM_VARS["TYPENAME"] .= $queries['typeName'] . ",";
if ($queries['PropertyName'][0]) {
foreach ($queries['PropertyName'] as $PropertyNames) {
// We check if typeName is prefix and add it if its not
if (strpos($PropertyNames, ".")) {
$HTTP_FORM_VARS["PROPERTYNAME"] .= $PropertyNames . ",";
} else {
$HTTP_FORM_VARS["PROPERTYNAME"] .= $queries['typeName'] . "." . $PropertyNames . ",";
}
}
}
if (is_array($queries['Filter']) && $arr['version'] == "1.0.0") {
@($checkXml = simplexml_load_string($queries['Filter']));
if ($checkXml === FALSE) {
makeExceptionReport("Filter is not valid");
}
$wheres[$queries['typeName']] = parseFilter($queries['Filter'], $queries['typeName']);
}
}
$HTTP_FORM_VARS["TYPENAME"] = dropLastChrs($HTTP_FORM_VARS["TYPENAME"], 1);
$HTTP_FORM_VARS["PROPERTYNAME"] = dropLastChrs($HTTP_FORM_VARS["PROPERTYNAME"], 1);
break;
case "DescribeFeatureType":
$HTTP_FORM_VARS["REQUEST"] = "DescribeFeatureType";
$HTTP_FORM_VARS["TYPENAME"] = $arr['TypeName'];
//if (!$HTTP_FORM_VARS["TYPENAME"]) $HTTP_FORM_VARS["TYPENAME"] = $arr['typeName'];
break;
case "GetCapabilities":
$HTTP_FORM_VARS["REQUEST"] = "GetCapabilities";
break;
case "Transaction":
$HTTP_FORM_VARS["REQUEST"] = "Transaction";
if (isset($arr["Insert"])) {
$transactionType = "Insert";
//.........这里部分代码省略.........