当前位置: 首页>>代码示例>>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;未经允许,请勿转载。