当前位置: 首页>>代码示例>>PHP>>正文


PHP SimpleXMLElement::getNamespaces方法代码示例

本文整理汇总了PHP中SimpleXMLElement::getNamespaces方法的典型用法代码示例。如果您正苦于以下问题:PHP SimpleXMLElement::getNamespaces方法的具体用法?PHP SimpleXMLElement::getNamespaces怎么用?PHP SimpleXMLElement::getNamespaces使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SimpleXMLElement的用法示例。


在下文中一共展示了SimpleXMLElement::getNamespaces方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 /**
  * Constructor
  *
  * @param \SimpleXMLElement|string $data
  * @throws InvalidArgumentException
  */
 public function __construct($data)
 {
     if ($data instanceof SimpleXMLElement) {
         $this->xml = $data;
     } else {
         if (is_string($data)) {
             $this->xml = new SimpleXMLElement($data);
         } else {
             throw new InvalidArgumentException(sprintf('Invalid data type for NcxResource'));
         }
     }
     $this->namespaces = $this->xml->getNamespaces(true);
 }
开发者ID:jonhargett,项目名称:epub,代码行数:19,代码来源:NcxResource.php

示例2: setIdentifier

 function setIdentifier($form_values)
 {
     require_once drupal_get_path('module', 'Fedora_Repository') . '/ObjectHelper.php';
     require_once drupal_get_path('module', 'Fedora_Repository') . '/CollectionClass.php';
     $collectionHelper = new CollectionClass();
     $ppid = $_SESSION['pid'];
     $itqlquery = 'select $object from <#ri> where $object <fedora-rels-ext:isPartOf><info:fedora/' . $ppid . '> and $object <fedora-rels-ext:isMemberOfCollection><info:fedora/vre:mnpl-compounds>and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>';
     $relatedItems = $collectionHelper->getRelatedItems($this->pid, $itqlquery);
     $sxe = new SimpleXMLElement($relatedItems);
     $nmspace = $sxe->getNamespaces(true);
     $regspace = $sxe->registerXPathNamespace('ri', implode($nmspace));
     $link = $sxe->xpath('//@uri');
     $labid = $_SESSION['labid'];
     if (empty($link)) {
         $ident = $labid . '-C-0';
     } else {
         //loop through returns , trim to create identifier and increment highest value
         $xia = array();
         foreach ($link as $path) {
             $path1 = substr($path, '30');
             $path2 = strrchr($path1, "-");
             $path = str_replace($path2, '', $path1);
             $xi = ltrim($path2, "-");
             $xnew = array_push($xia, $xi);
         }
         $num = max($xia);
         $numinc = $num + 1;
         $ident = $labid . '-C-' . $numinc;
     }
     return $ident;
 }
开发者ID:ratzeni,项目名称:islandora,代码行数:31,代码来源:CompoundsFormBuilder.php

示例3: authenticate

 public function authenticate($ticket, $service)
 {
     $r = \Httpful\Request::get($this->getValidateUrl($ticket, $service))->sendsXml()->timeoutIn($this->timeout)->send();
     $r->body = str_replace("\n", "", $r->body);
     // var_dump($r->body);
     try {
         $xml = new \SimpleXMLElement($r->body);
     } catch (\Exception $e) {
         throw new \Exception("Return cannot be parsed :\n {$r->body}", 1);
     }
     $namespaces = $xml->getNamespaces();
     $serviceResponse = $xml->children($namespaces['cas']);
     $user = $serviceResponse->authenticationSuccess->user;
     if ($user) {
         return (string) $user;
         // cast simplexmlelement to string
     } else {
         $authFailed = $serviceResponse->authenticationFailure;
         if ($authFailed) {
             $attributes = $authFailed->attributes();
             throw new \Exception("AuthenticationFailure : " . $attributes['code'] . " ({$ticket}, {$service})", 1);
         } else {
             throw new \Exception("Cas return is weird : '{$r->body}'", 1);
         }
     }
     // never reach there
 }
开发者ID:AntoineGiraud,项目名称:simpleSlimAppWithAuthentification,代码行数:27,代码来源:Cas.php

示例4: foreach

    function validate_operations()
    {
        foreach ($this->calendar_users as $user) {
            $url = str_replace("#USER#", $user['user'], $this->calendar_url);
            $this->caldav = new CalDAVClient($url, trim($user['user']), trim($user['pass']), 'basic', false);
            //for debug = true
            $xmlC = <<<PROPP
<?xml version="1.0" encoding="utf-8" ?>
 <D:propfind xmlns:D="DAV:" xmlns:C="http://calendarserver.org/ns/">
     <D:prop>
             <D:displayname />
             <C:getctag />
             <D:resourcetype />
     </D:prop>
 </D:propfind>
PROPP;
            try {
                $this->caldav->SetDepth(1);
                $xml_response = $this->caldav->DoXMLRequest("PROPFIND", $xmlC);
                $xml_response = explode("\r\n\r\n", $xml_response)[1];
                $xml = new SimpleXMLElement($xml_response);
                $ns = $xml->getNamespaces(true);
                $responses = $xml->children($ns["d"]);
                $this->set_status(ok);
                $this->add_functional("calendar list events of " . $user['user'] . "(" . count($responses) . ")", ok);
            } catch (Exception $x) {
                $this->set_status(error);
                $this->add_message($x->getMessage());
                $fullerror = "url:" . $url . " " . $x->getMessage();
                error_log($fullerror);
                $this->add_functional("calendar list events of " . $user['user'], error, "Can't list events from {$url}");
            }
        }
    }
开发者ID:selialkile,项目名称:rc_monitor,代码行数:34,代码来源:calendar.php

示例5: parseMaps

 private function parseMaps(\SimpleXMLElement $xml)
 {
     $maps = array();
     if (array_key_exists('maps', $this->mapping)) {
         foreach ($this->mapping['maps'] as $key => $item) {
             /* --- XML NS --- */
             if ('MobileRelatedApps' == $this->name) {
                 /** @var $element \SimpleXMLElement */
                 $element = $xml->{'RelatedApps'};
                 $ns = $xml->getNamespaces(true);
                 $map = array();
                 foreach ($element->children($ns['d2p1']) as $element) {
                     $map[(string) $element->{$item['xml']['key']}] = (string) $element->{$item['xml']['value']};
                 }
                 $maps[$key] = $map;
                 continue;
             }
             /* --- XML NS --- */
             $map = array();
             $parts = explode('.', $item['xml']['field']);
             $items = array();
             if (2 == count($parts)) {
                 $items = $xml->{$parts[0]}->{$parts[1]};
             }
             foreach ($items as $element) {
                 $map[(string) $element->{$item['xml']['key']}] = (string) $element->{$item['xml']['value']};
             }
             $maps[$key] = $map;
         }
     }
     return $maps;
 }
开发者ID:gerdlaser,项目名称:SimilarWebApi,代码行数:32,代码来源:XmlParser.php

示例6: foreach

 function __construct(SimpleXMLElement $node, $namespaces = null)
 {
     $this->__name = $node->getName();
     $this->__value = $node;
     if ($namespaces === null) {
         $namespaces = $node->getNamespaces(true);
     }
     foreach ($namespaces as $ns => $uri) {
         foreach ($node->children($uri) as $child) {
             $childName = $ns ? "{$ns}:" . $child->getName() : $child->getName();
             if (array_key_exists($childName, $this->__children) && is_array($this->__children[$childName])) {
                 $this->__children[$childName][] = new clNode($child, $namespaces);
             } else {
                 if (array_key_exists($childName, $this->__children) && get_class($this->__children[$childName]) == "clNode") {
                     $childArray = array();
                     $childArray[] = $this->__children[$childName];
                     $childArray[] = new clNode($child, $namespaces);
                     $this->__children[$childName] = $childArray;
                 } else {
                     $this->__children[$childName] = new clNode($child, $namespaces);
                 }
             }
         }
         foreach ($node->attributes($ns) as $a) {
             $a = $a->asXML();
             @(list($name, $value) = split('=', $a));
             $this->__attributes[trim($name)] = substr($value, 1, strlen($value) - 2);
         }
     }
 }
开发者ID:stereoket,项目名称:coreylib,代码行数:30,代码来源:index.php

示例7: parse

 /**
  * Method to parse the feed into a JFeed object.
  *
  * @return  JFeed
  *
  * @since   12.3
  */
 public function parse()
 {
     $feed = new JFeed();
     // Detect the feed version.
     $this->initialise();
     // Let's get this party started...
     do {
         // Expand the element for processing.
         $el = new SimpleXMLElement($this->stream->readOuterXml());
         // Get the list of namespaces used within this element.
         $ns = $el->getNamespaces(true);
         // Get an array of available namespace objects for the element.
         $namespaces = array();
         foreach ($ns as $prefix => $uri) {
             // Ignore the empty namespace prefix.
             if (empty($prefix)) {
                 continue;
             }
             // Get the necessary namespace objects for the element.
             $namespace = $this->fetchNamespace($prefix);
             if ($namespace) {
                 $namespaces[] = $namespace;
             }
         }
         // Process the element.
         $this->processElement($feed, $el, $namespaces);
         // Skip over this element's children since it has been processed.
         $this->moveToClosingElement();
     } while ($this->moveToNextElement());
     return $feed;
 }
开发者ID:adjaika,项目名称:J3Base,代码行数:38,代码来源:parser.php

示例8: extractAttributeFromXml

 /**
  * Get a specific attribute in a namespaced tag
  * @param  \SimpleXMLElement $xml            
  * @param  string $attributeFocus 
  * @param  string $namespaceFocus 
  * @param  string $tagFocus       
  * @return string 
  */
 public static function extractAttributeFromXml($xml, $attributeFocus, $namespaceFocus, $tagFocus)
 {
     $namespace = $xml->getNamespaces(true);
     $attributes = $xml->children($namespace[$namespaceFocus])->{$tagFocus}->attributes();
     $finalAttribute = $attributes[$attributeFocus];
     return $finalAttribute->__toString();
 }
开发者ID:Loschcode,项目名称:php-google-spreadsheet-client,代码行数:15,代码来源:Util.php

示例9: xmlToArray

 public static function xmlToArray(\SimpleXMLElement $xml, $options = [])
 {
     $defaults = ['namespaceSeparator' => ':', 'attributePrefix' => '@', 'alwaysArray' => [], 'autoArray' => true, 'textContent' => '_v_', 'autoText' => true, 'keySearch' => false, 'keyReplace' => false];
     $options = array_merge($defaults, $options);
     $namespaces = $xml->getNamespaces(true);
     $namespaces[''] = null;
     //add base (empty) namespace
     //get attributes from all namespaces
     $attributesArray = [];
     foreach ($namespaces as $prefix => $namespace) {
         foreach ($xml->attributes($namespace) as $attributeName => $attribute) {
             //replace characters in attribute name
             if ($options['keySearch']) {
                 $attributeName = str_replace($options['keySearch'], $options['keyReplace'], $attributeName);
             }
             $attributeKey = $options['attributePrefix'] . ($prefix ? $prefix . $options['namespaceSeparator'] : '') . $attributeName;
             $attributesArray[$attributeKey] = (string) $attribute;
         }
     }
     //get child nodes from all namespaces
     $tagsArray = [];
     foreach ($namespaces as $prefix => $namespace) {
         foreach ($xml->children($namespace) as $childXml) {
             //recurse into child nodes
             $childArray = self::xmlToArray($childXml, $options);
             list($childTagName, $childProperties) = each($childArray);
             //replace characters in tag name
             if ($options['keySearch']) {
                 $childTagName = str_replace($options['keySearch'], $options['keyReplace'], $childTagName);
             }
             //add namespace prefix, if any
             if ($prefix) {
                 $childTagName = $prefix . $options['namespaceSeparator'] . $childTagName;
             }
             if (!isset($tagsArray[$childTagName])) {
                 //only entry with this key
                 //test if tags of this type should always be arrays, no matter the element count
                 $tagsArray[$childTagName] = in_array($childTagName, $options['alwaysArray']) || !$options['autoArray'] ? [$childProperties] : $childProperties;
             } elseif (is_array($tagsArray[$childTagName]) && array_keys($tagsArray[$childTagName]) === range(0, count($tagsArray[$childTagName]) - 1)) {
                 //key already exists and is integer indexed array
                 $tagsArray[$childTagName][] = $childProperties;
             } else {
                 //key exists so convert to integer indexed array with previous value in position 0
                 $tagsArray[$childTagName] = [$tagsArray[$childTagName], $childProperties];
             }
         }
     }
     //get text content of node
     $textContentArray = [];
     $plainText = trim((string) $xml);
     if ($plainText !== '') {
         $textContentArray[$options['textContent']] = $plainText;
     }
     //stick it all together
     $propertiesArray = !$options['autoText'] || $attributesArray || $tagsArray || $plainText === '' ? array_merge($attributesArray, $tagsArray, $textContentArray) : $plainText;
     //return node as array
     return [$xml->getName() => $propertiesArray];
 }
开发者ID:dylnio,项目名称:packages-util,代码行数:58,代码来源:StringUtil.php

示例10: toArray

 /**
  * Convert SimpleXMLElement to multidimensional array.
  *
  * @param \SimpleXMLElement $xml
  * @param string            $namespace The namespace that schould be used.
  *
  * @throws \OutOfBoundsException If namespace not found in the xml.
  * @return array
  */
 public static function toArray(\SimpleXMLElement $xml, $namespace = null)
 {
     if ($namespace !== null) {
         $namespaces = $xml->getNamespaces();
         if (false === isset($namespaces[$namespace])) {
             throw new \OutOfBoundsException('namespace [' . $namespace . '] not found');
         }
         $xml = $xml->children($namespaces[$namespace]);
     }
     return Json::decode(Json::encode($xml), true);
 }
开发者ID:PermeAgility,项目名称:FrameworkBenchmarks,代码行数:20,代码来源:Xml.php

示例11: watchFolder

 public function watchFolder(KalturaDropFolder $dropFolder)
 {
     /* @var $dropFolder KalturaFeedDropFolder */
     KalturaLog::info("Watching drop folder with ID [" . $dropFolder->id . "]");
     $this->dropFolder = $dropFolder;
     //Get Drop Folder feed and import it into a SimpleXMLElement
     $feed = new SimpleXMLElement(file_get_contents($dropFolder->path));
     $this->feedNamespaces = $feed->getNamespaces(true);
     //get items
     $feedItems = $feed->xpath($this->dropFolder->feedItemInfo->itemXPath);
     if ($this->dropFolder->itemHandlingLimit > 0 && count($feedItems) > $this->dropFolder->itemHandlingLimit) {
         KalturaLog::err("Reached pulling limit for drop folder ID [" . $this->dropFolder->id . "].");
         array_splice($feedItems, $this->dropFolder->itemHandlingLimit);
         $dropFolderUpdate = new KalturaFeedDropFolder();
         $dropFolderUpdate->errorDescription = FeedDropFolderPlugin::ERROR_MESSAGE_INCOMPLETE_HANDLING . $this->dropFolder->id;
         $this->dropFolderPlugin->dropFolder->update($this->dropFolder->id, $dropFolderUpdate);
     }
     $existingDropFolderFilesMap = $this->loadDropFolderFiles();
     $counter = 0;
     foreach ($feedItems as $feedItem) {
         if ($counter > intval(KBatchBase::$taskConfig->params->mrss->limitProcessEachRun)) {
             KalturaLog::info('Finished current run.');
             break;
         }
         /* @var $feedItem SimpleXMLElement */
         $uniqueId = strval($this->getSingleXPathResult($this->dropFolder->feedItemInfo->itemUniqueIdentifierXPath, $feedItem));
         //If we already encountered this uniqueId in this run- ignore subsequent iterations.
         if (in_array($uniqueId, $this->handledUniqueIds)) {
             KalturaLog::err("The unique identifer value [{$uniqueId}] was encountered before during this scan of the feed. Ignoring.");
             continue;
         }
         // The unique feed item identifier is the GUID, so that is what we set as the drop folder file name.
         if (!array_key_exists($uniqueId, $existingDropFolderFilesMap)) {
             //In this case, we are required to add this item as a new drop folder file
             KalturaLog::info("Item not found in drop folder file list- adding as new drop folder file.");
             $this->handleItemAdded($uniqueId, $feedItem);
             $counter++;
         } else {
             KalturaLog::info("Item found in drop folder file list- adding as existing drop folder file.");
             $dropFolderFile = $existingDropFolderFilesMap[$uniqueId];
             unset($existingDropFolderFilesMap[$uniqueId]);
             //if file exist in the folder remove it from the map
             //all the files that are left in a map will be marked as PURGED
             if ($this->handleExistingItem($dropFolderFile, $feedItem)) {
                 $counter++;
             }
         }
         $this->handledUniqueIds[] = $uniqueId;
     }
     foreach ($existingDropFolderFilesMap as $existingDropFolderFile) {
         $this->handleFilePurged($existingDropFolderFile->id);
     }
 }
开发者ID:kubrickfr,项目名称:server,代码行数:53,代码来源:KFeedDropFolderEngine.php

示例12: getAttributes

 /**
  * @return string[] The attributes
  */
 public function getAttributes()
 {
     //include namespace declarations as attributes
     $xmlnsRaw = $this->_element->getNamespaces();
     $xmlns = array();
     foreach ($xmlnsRaw as $key => $val) {
         $label = 'xmlns' . ($key ? ":{$key}" : $key);
         $xmlns[$label] = $val;
     }
     //get attributes and merge with namespaces
     $attrRaw = $this->_element->attributes();
     $attr = array();
     foreach ($attrRaw as $key => $val) {
         $attr[$key] = $val;
     }
     $attr = array_merge((array) $xmlns, (array) $attr);
     $result = array();
     foreach ($attr as $key => $val) {
         $result[$key] = (string) $val;
     }
     return $result;
 }
开发者ID:duanhv,项目名称:mdg-social,代码行数:25,代码来源:ElggXMLElement.php

示例13: getStatus

 private function getStatus($type, $path, $response)
 {
     $data = new \SimpleXMLElement($response);
     $namespaces = $data->getNamespaces(true);
     foreach ($namespaces as $key => $value) {
         $namespace = $value;
     }
     $data->registerXPathNamespace($type, $namespace);
     foreach ($data->xpath($path) as $value) {
         $status = json_decode(json_encode((array) $value), TRUE);
     }
     return $status;
 }
开发者ID:amzn,项目名称:login-and-pay-with-amazon-sdk-php,代码行数:13,代码来源:ResponseParser.php

示例14: getBillingAgreementDetailsStatus

 public function getBillingAgreementDetailsStatus($response)
 {
     $data = new \SimpleXMLElement($response);
     $namespaces = $data->getNamespaces(true);
     foreach ($namespaces as $key => $value) {
         $namespace = $value;
     }
     $data->registerXPathNamespace('GetBA', $namespace);
     foreach ($data->xpath('//GetBA:BillingAgreementStatus') as $value) {
         $baStatus = json_decode(json_encode((array) $value), TRUE);
     }
     return $baStatus;
 }
开发者ID:wikimedia,项目名称:wikimedia-fundraising-crm-vendor,代码行数:13,代码来源:ResponseParser.php

示例15: fromSimpleXMLElement

 public static function fromSimpleXMLElement(SimpleXMLElement $element)
 {
     // Traverse all existing namespaces in element.
     $namespaces = $element->getNamespaces();
     foreach ($namespaces as $prefix => $ns) {
         $element[$prefix === '' ? 'xmlns' : 'xmlns:' . $prefix] = $ns;
     }
     /* Create a new parser with the xml document where the namespace definitions
      * are added.
      */
     $parser = new SimpleSAML_XML_Parser($element->asXML());
     return $parser;
 }
开发者ID:Stony-Brook-University,项目名称:doitsbu,代码行数:13,代码来源:Parser.php


注:本文中的SimpleXMLElement::getNamespaces方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。