本文整理汇总了PHP中CDataXML::loadString方法的典型用法代码示例。如果您正苦于以下问题:PHP CDataXML::loadString方法的具体用法?PHP CDataXML::loadString怎么用?PHP CDataXML::loadString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CDataXML
的用法示例。
在下文中一共展示了CDataXML::loadString方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: referenceItemsStart
public function referenceItemsStart($path, $attr)
{
if ($this->NS["fp"] <= 0) {
$this->error = GetMessage("CC_BCIH_XML_PARSE_ERROR", array("#CODE#" => 10));
} else {
$this->deleteBySessid($this->NS["HL"], $this->NS["SESSID"]);
$xmlPosition = $this->xmlStream->getPosition();
$filePosition = $this->decodePostion($xmlPosition);
$xmlString = $this->xmlStream->readFilePart($this->NS["fp"], $filePosition);
$error = "";
if ($xmlPosition[0]) {
$xmlString = CharsetConverter::convertCharset($xmlString, $xmlPosition[0], LANG_CHARSET, $error);
}
$xmlString .= "</" . GetMessage("CC_BCIH_XML_REFERENCE") . ">";
$xmlObject = new CDataXML();
if ($xmlObject->loadString($xmlString)) {
$highBlockID = $this->checkReference($xmlObject->GetArray());
$this->dataClass = "";
$this->step = true;
$this->message = GetMessage("CC_BCIH_REFERENCE_FOUND_OR_CREATED", array("#CODE#" => $highBlockID));
if ($highBlockID > 0) {
$this->NS["HL"] = $highBlockID;
$this->NS["FM"] = array();
$this->NS["C"] = 0;
} else {
$this->error = GetMessage("CC_BCIH_XML_PARSE_ERROR", array("#CODE#" => 30));
}
} else {
$this->error = GetMessage("CC_BCIH_XML_PARSE_ERROR", array("#CODE#" => 20));
}
}
}
示例2: readXml
/**
* Reads xml chunk from the file preserving it's position
*
* @param int $startPosition
* @param int $endPosition
* @return CDataXML|false
*/
private function readXml($startPosition, $endPosition)
{
$savedPosition = ftell($this->fileHandler);
fseek($this->fileHandler, $startPosition);
$xmlChunk = fread($this->fileHandler, $endPosition - $startPosition);
fseek($this->fileHandler, $savedPosition);
if ($xmlChunk && $this->fileCharset) {
$error = "";
$xmlChunk = CharsetConverter::convertCharset($xmlChunk, $this->fileCharset, LANG_CHARSET, $error);
}
$xmlObject = new CDataXML();
if ($xmlObject->loadString($xmlChunk)) {
return $xmlObject;
} else {
return false;
}
}
示例3: GetCurrentUserFriends
public function GetCurrentUserFriends($limit, &$next)
{
if ($this->access_token === false) {
return false;
}
$http = new HttpClient();
$http->setHeader('GData-Version', '3.0');
$http->setHeader('Authorization', 'Bearer ' . $this->access_token);
$url = static::FRIENDS_URL . '?';
$limit = intval($limit);
$next = intval($next);
if ($limit > 0) {
$url .= '&max-results=' . $limit;
}
if ($next > 0) {
$url .= '&start-index=' . $next;
}
$result = $http->get($url);
if (!defined("BX_UTF")) {
$result = CharsetConverter::ConvertCharset($result, "utf-8", LANG_CHARSET);
}
if ($http->getStatus() == 200) {
$obXml = new \CDataXML();
if ($obXml->loadString($result)) {
$tree = $obXml->getTree();
$total = $tree->elementsByName("totalResults");
$total = intval($total[0]->textContent());
$limitNode = $tree->elementsByName("itemsPerPage");
$next += intval($limitNode[0]->textContent());
if ($next >= $total) {
$next = '__finish__';
}
$arFriends = array();
$arEntries = $tree->elementsByName('entry');
foreach ($arEntries as $entry) {
$arEntry = array();
$entryChildren = $entry->children();
foreach ($entryChildren as $child) {
$tag = $child->name();
switch ($tag) {
case 'category':
case 'updated':
case 'edited':
break;
case 'name':
$arEntry[$tag] = array();
foreach ($child->children() as $subChild) {
$arEntry[$tag][$subChild->name()] = $subChild->textContent();
}
break;
case 'email':
if ($child->getAttribute('primary') == 'true') {
$arEntry[$tag] = $child->getAttribute('address');
}
break;
default:
$tagContent = $tag == 'link' ? $child->getAttribute('href') : $child->textContent();
if ($child->getAttribute('rel')) {
if (!isset($arEntry[$tag])) {
$arEntry[$tag] = array();
}
$arEntry[$tag][preg_replace("/^[^#]*#/", "", $child->getAttribute('rel'))] = $tagContent;
} elseif (isset($arEntry[$tag])) {
if (!is_array($arEntry[$tag][0]) || !isset($arEntry[$tag][0])) {
$arEntry[$tag] = array($arEntry[$tag], $tagContent);
} else {
$arEntry[$tag][] = $tagContent;
}
} else {
$arEntry[$tag] = $tagContent;
}
}
}
if ($arEntry['email']) {
$arFriends[] = $arEntry;
}
}
return $arFriends;
}
}
return false;
}
示例4: query
private static function query($query, $data)
{
$http = new \Bitrix\Main\Web\HttpClient();
$response = $http->post($query, $data);
$xml = new CDataXML();
$xml->loadString($response);
return $xml;
}
示例5: readXml
/**
* Reads xml chunk from the file preserving it's position
*
* @param int $startPosition
* @param int $endPosition
* @return CDataXML|false
*/
private function readXml($startPosition, $endPosition)
{
$xmlChunk = $this->readFilePart($startPosition, $endPosition);
if ($xmlChunk && $this->fileCharset) {
$error = "";
$xmlChunk = CharsetConverter::convertCharset($xmlChunk, $this->fileCharset, LANG_CHARSET, $error);
}
$xmlObject = new CDataXML();
if ($xmlObject->loadString($xmlChunk)) {
return $xmlObject;
} else {
return false;
}
}
示例6: processSiteResult
protected function processSiteResult($res)
{
$obXml = new \CDataXML();
if ($obXml->loadString($res)) {
$hostName = $obXml->getTree()->elementsByName('name');
$hostName = \CBXPunycode::toASCII(ToLower($hostName[0]->textContent()), $e = null);
if (preg_match("/^https:\\/\\//", $hostName)) {
$hostName = substr($hostName, 8);
}
$this->engineSettings['SITES'][$hostName]['SERVICES'] = array();
$arLinks = $obXml->getTree()->elementsByName('link');
foreach ($arLinks as $link) {
$this->engineSettings['SITES'][$hostName]['SERVICES'][$link->getAttribute('rel')] = $link->getAttribute('href');
}
$this->saveSettings();
return true;
}
return false;
}
示例7: processResult
protected function processResult($res)
{
$obXml = new \CDataXML();
if ($obXml->loadString($res)) {
$arEntries = $obXml->getTree()->elementsByName('entry');
$arDomains = array();
foreach ($arEntries as $entry) {
$entryChildren = $entry->children();
$entryData = array('etag' => $entry->getAttribute('etag'));
foreach ($entryChildren as $child) {
$tag = $child->name();
switch ($tag) {
case 'category':
break;
case 'content':
$entryData[$tag] = $child->getAttribute('src');
break;
case 'link':
if (!isset($entryData[$tag])) {
$entryData[$tag] = array();
}
$entryData[$tag][$child->getAttribute('rel')] = $child->getAttribute('href');
break;
case 'entryLink':
if (!isset($entryData[$tag])) {
$entryData[$tag] = array();
}
$rel = preg_replace("/^[^#]+#/", "", $child->getAttribute('rel'));
$entryData[$tag][$rel] = $child->getAttribute('href');
break;
case 'verification-method':
if ($child->getAttribute('type') == 'htmlpage') {
$entryData[$tag] = array('in-use' => $child->getAttribute('in-use'), 'file-name' => $child->textContent(), 'file-content' => $child->getAttribute('file-content'));
}
break;
default:
$entryData[$tag] = $child->textContent();
}
}
$url = $entryData['content'];
if (strlen($url) > 0) {
$urlData = parse_url($url);
if (isset($urlData['port']) && strlen($urlData['port']) > 0) {
$urlData['host'] .= ':' . $urlData['port'];
}
if (!isset($arDomains[$urlData['host']])) {
$arDomains[$urlData['host']] = $entryData;
}
}
}
$arExistedDomains = \CSeoUtils::getDomainsList();
foreach ($arExistedDomains as $domain) {
if (isset($arDomains[$domain['DOMAIN']])) {
if (!is_array($this->engineSettings['SITES'])) {
$this->engineSettings['SITES'] = array();
}
$this->engineSettings['SITES'][$domain['DOMAIN']] = $arDomains[$domain['DOMAIN']];
}
}
$this->saveSettings();
return $arDomains;
}
throw new \Exception('Unexpected query result! ' . $res);
return false;
}