當前位置: 首頁>>代碼示例>>PHP>>正文


PHP CDataXML::GetTree方法代碼示例

本文整理匯總了PHP中CDataXML::GetTree方法的典型用法代碼示例。如果您正苦於以下問題:PHP CDataXML::GetTree方法的具體用法?PHP CDataXML::GetTree怎麽用?PHP CDataXML::GetTree使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在CDataXML的用法示例。


在下文中一共展示了CDataXML::GetTree方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: ProcessRequest

 function ProcessRequest()
 {
     global $HTTP_SERVER_VARS, $APPLICATION;
     if ($HTTP_SERVER_VARS["REQUEST_METHOD"] != "POST" or !class_exists("CDataXML")) {
         $this->ShowSOAPFault("Error: this web page does only understand POST methods. BitrixXMLParser. ");
     }
     for ($i = 0; $i < count($this->OnRequestEvent); $i++) {
         $this->OnRequestEvent[$i]->OnBeforeRequest($this);
     }
     //AddMessage2Log($this->RawPostData);
     $xmlData = $this->stripHTTPHeader($this->RawPostData);
     $xmlData = $APPLICATION->ConvertCharset($xmlData, "UTF-8", SITE_CHARSET);
     $xml = new CDataXML();
     //AddMessage2Log($xmlData);
     if (!$xml->LoadString($xmlData)) {
         $this->ShowSOAPFault("Error: Can't parse request xml data. ");
     }
     $dom = $xml->GetTree();
     // Check for non-parsing XML, to avoid call to non-object error.
     if (!is_object($dom)) {
         $this->ShowSOAPFault("Bad XML");
     }
     // add namespace fetching on body
     // get the SOAP body
     $body = $dom->elementsByName("Body");
     $children = $body[0]->children();
     if (count($children) == 1) {
         $requestNode = $children[0];
         $requestParsed = false;
         // get target namespace for request
         // it often function request message. in wsdl gen. = function+"request"
         $functionName = $requestNode->name();
         $namespaceURI = $requestNode->namespaceURI();
         for ($i = 0; $i < count($this->OnRequestEvent); $i++) {
             if ($this->OnRequestEvent[$i]->ProcessRequestBody($this, $requestNode)) {
                 $requestParsed = true;
                 break;
             }
         }
         for ($i = 0; $i < count($this->OnRequestEvent); $i++) {
             $this->OnRequestEvent[$i]->OnAfterResponse($this);
         }
         if (!$requestParsed) {
             $this->ShowSOAPFault('Unknown operation requested.');
         }
         return $requestParsed;
     } else {
         $this->ShowSOAPFault('"Body" element in the request has wrong number of children');
     }
     return false;
 }
開發者ID:sharapudinov,項目名稱:lovestore.top,代碼行數:51,代碼來源:soapserver.php

示例2: decodeStream

 function decodeStream($request, $stream)
 {
     global $APPLICATION;
     $stream_cutted = $this->stripHTTPHeader($stream);
     if (!$stream_cutted or !class_exists("CDataXML")) {
         $APPLICATION->ThrowException("Error: BitrixXMLParser. " . "Downloaded page: <br>" . htmlspecialcharsEx($stream));
         return;
     }
     $stream = $stream_cutted;
     $xml = new CDataXML();
     $stream = $APPLICATION->ConvertCharset($stream, "UTF-8", SITE_CHARSET);
     if (!$xml->LoadString($stream)) {
         $APPLICATION->ThrowException("Error: Can't parse request xml data. ");
         return;
     }
     $dom = $xml->GetTree();
     $this->DOMDocument = $dom;
     if (get_class($dom) == "CDataXMLDocument" || get_class($dom) == "cdataxmldocument") {
         // check for fault
         $response = $dom->elementsByName('Fault');
         if (count($response) == 1) {
             $this->IsFault = 1;
             $faultStringArray = $dom->elementsByName("faultstring");
             $this->FaultString = $faultStringArray[0]->textContent();
             $faultCodeArray = $dom->elementsByName("faultcode");
             $this->FaultCode = $faultCodeArray[0]->textContent();
             return;
         }
         // get the response
         $body = $dom->elementsByName("Body");
         $body = $body[0];
         $response = $body->children();
         $response = $response[0];
         if (get_class($response) == "CDataXMLNode" || get_class($response) == "cdataxmlnode") {
             /*Cut from the SOAP spec:
             				The method response is viewed as a single struct containing an accessor
             				for the return value and each [out] or [in/out] parameter.
             				The first accessor is the return value followed by the parameters
             				in the same order as in the method signature.
             
             				Each parameter accessor has a name corresponding to the name
             				of the parameter and type corresponding to the type of the parameter.
             				The name of the return value accessor is not significant.
             				Likewise, the name of the struct is not significant.
             				However, a convention is to name it after the method name
             				with the string "Response" appended.
             				*/
             $responseAccessors = $response->children();
             //echo '<pre>'; print_r($responseAccessors); echo '</pre>';
             if (count($responseAccessors) > 0) {
                 $this->Value = array();
                 foreach ($responseAccessors as $arChild) {
                     $value = $arChild->decodeDataTypes();
                     $this->Value = array_merge($this->Value, $value);
                 }
             }
         } else {
             $APPLICATION->ThrowException("Could not understand type of class decoded");
         }
     } else {
         $APPLICATION->ThrowException("Could not process XML in response");
     }
 }
開發者ID:DarneoStudio,項目名稱:bitrix,代碼行數:63,代碼來源:soapresponse.php

示例3: encodeValue

 function encodeValue($name, $value, $complexDataTypeName = "")
 {
     global $xsd_simple_type;
     if (!is_array($this->outputVars) or !count($this->outputVars)) {
         CSOAPServer::ShowSOAPFault("encodeValue() has no Output Data Type Declaration for validation.");
         exit;
     }
     $dataType = "";
     $typeDeclaration = "";
     if (isset($this->outputVars[$name])) {
         $typeDeclaration = $this->outputVars[$name];
     } else {
         if (isset($this->typensVars[$name])) {
             $typeDeclaration = $this->typensVars[$name];
         } else {
             if (isset($this->typensVars[$complexDataTypeName][$name])) {
                 $typeDeclaration = $this->typensVars[$complexDataTypeName][$name];
             }
         }
     }
     if (isset($typeDeclaration["varType"])) {
         // if not, name = complex data type
         $dataType = $typeDeclaration["varType"];
     } else {
         $dataType = $name;
     }
     if (isset($xsd_simple_type[$dataType])) {
         $dataType = $xsd_simple_type[$dataType];
     }
     // Type validation
     $this->_validateType($dataType, $value);
     switch ($dataType) {
         case "string":
             $node = new CXMLCreator($name);
             //$node->setAttribute( "type", BX_SOAP_XSD_PREFIX . ":string" );
             $node->setData($value);
             return $node;
             break;
         case "boolean":
             $node = new CXMLCreator($name);
             //$node->setAttribute( "type", BX_SOAP_XSD_PREFIX . ":boolean" );
             if ($value === true) {
                 $node->setData("true");
             } else {
                 $node->setData("false");
             }
             return $node;
             break;
         case "integer":
             $node = new CXMLCreator($name);
             //$node->setAttribute( "type", BX_SOAP_XSD_PREFIX . ":int" );
             $node->setData(intval($value));
             return $node;
             break;
         case "float":
         case "double":
             $node = new CXMLCreator($name);
             //$node->setAttribute( "type", BX_SOAP_XSD_PREFIX . ":float" );
             $node->setData($value);
             return $node;
             break;
             // added by Sigurd
         // added by Sigurd
         case "base64":
         case "base64Binary":
             $node = new CXMLCreator($name);
             //$node->setAttribute("type", BX_SOAP_XSD_PREFIX . ":base64Binary" );
             $node->setData(base64_encode($value));
             return $node;
             break;
         case 'any':
             $node = new CXMLCreator($name);
             if (is_object($value)) {
                 // $fp = fopen($_SERVER['DOCUMENT_ROOT'].'/ws.log', 'a');
                 // fwrite($fp, $value->GetTree()."\n");
                 // fwrite($fp, '===================================='."\r\n");
                 // fclose($fp);
                 if (get_class($value) == 'CDataXML') {
                     $node->addChild(CXMLCreator::CreateFromDOM($value->GetTree()));
                 } elseif (get_class($value) == 'CDataXMLDocument') {
                     $node->addChild(CXMLCreator::CreateFromDOM($value));
                 } elseif (get_class($value) == 'CXMLCreator') {
                     $node->addChild($value);
                 }
             } else {
                 $data = new CDataXML();
                 if ($data->LoadString($value)) {
                     $node->addChild(CXMLCreator::CreateFromDOM($data->GetTree()));
                 } else {
                     $node->setData($value);
                 }
             }
             return $node;
             break;
         default:
             $node = new CXMLCreator($name);
             if (isset($typeDeclaration["arrType"])) {
                 if (!isset($typeDeclaration["varType"])) {
                     $this->_errorTypeValidation("varType [undef]", $value);
                 }
//.........這裏部分代碼省略.........
開發者ID:Satariall,項目名稱:izurit,代碼行數:101,代碼來源:soapcodec.php

示例4: fopen

	$bIncorrectFormat = false;
	$handle = fopen($abs_path, "r");
	$size = filesize($abs_path);

	if ($size > 20)
	{
		$contents = fread($handle, 20);
		if (strtolower(substr($contents, 0, 5)) != "<?xml")
			$bIncorrectFormat = true;
	}

	if (!$bIncorrectFormat)
	{
		$objXML = new CDataXML();
		$objXML->Load($abs_path);
		$arTree = $objXML->GetTree();
		$arTracks = Array();
		$bIncorrectFormat = true;

		$ch = $arTree->children;
		if (count($ch) > 0 && strtolower($ch[0]->name) == 'playlist')
		{
			$pl = $ch[0];
			$tls = $pl->children;
			for ($i_ = 0, $l_ = count($tls); $i_ < $l_; $i_++)
			{
				if (strtolower($tls[$i_]->name) != 'tracklist')
					continue;
				$tracks = $tls[$i_]->children;
				for ($i = 0, $l = count($tracks); $i < $l; $i++)
				{
開發者ID:ASDAFF,項目名稱:open_bx,代碼行數:31,代碼來源:player_playlist_edit.php

示例5: parseXmlMetadata

 /**
  * @param string $rawMetadata
  * @return array|false
  */
 protected function parseXmlMetadata($rawMetadata)
 {
     $xml = new \CDataXML();
     if ($xml->LoadString($rawMetadata)) {
         //detect xml encoding
         if (preg_match('/<\\?xml[^>]+?encoding=[\'"](.+?)[\'"]\\?>/', $rawMetadata, $matches)) {
             $this->metadataEncoding = $matches[1];
         } else {
             $this->metadataEncoding = 'UTF-8';
         }
         $result = array();
         $dom = $xml->GetTree();
         $mainNode = $dom->elementsByName('oembed');
         foreach ($mainNode[0]->children as $node) {
             $result[$node->name] = $node->content;
         }
         return $result;
     }
     return false;
 }
開發者ID:DarneoStudio,項目名稱:bitrix,代碼行數:24,代碼來源:oembed.php


注:本文中的CDataXML::GetTree方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。