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


PHP SimpleXmlElement::children方法代码示例

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


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

示例1: getNodeTitle

/**
 * @param SimpleXmlElement $node
 * @return string
 */
function getNodeTitle($node)
{
    if ($node->children()) {
        $nodeName = $node->children()[0]->getName();
        $subNodeName = getNodeTitle($node->children()[0]);
        return $nodeName . ($subNodeName ? ' > ' . $subNodeName : '');
    }
    return '';
}
开发者ID:yu1136,项目名称:api-examples,代码行数:13,代码来源:generate_docs.php

示例2: parseXml

 /**
  * Parse the input SimpleXmlElement into an array
  *
  * @param SimpleXmlElement $node xml to parse
  * @return array
  */
 protected function parseXml($node)
 {
     $data = array();
     foreach ($node->children() as $key => $subnode) {
         if ($subnode->count()) {
             $value = $this->parseXml($subnode);
             if ($subnode->attributes()) {
                 foreach ($subnode->attributes() as $attrkey => $attr) {
                     $value['@' . $attrkey] = (string) $attr;
                 }
             }
         } else {
             $value = (string) $subnode;
         }
         if ($key === 'item') {
             if (isset($subnode['key'])) {
                 $data[(string) $subnode['key']] = $value;
             } elseif (isset($data['item'])) {
                 $tmp = $data['item'];
                 unset($data['item']);
                 $data[] = $tmp;
                 $data[] = $value;
             }
         } elseif (key_exists($key, $data)) {
             if (false === is_array($data[$key])) {
                 $data[$key] = array($data[$key]);
             }
             $data[$key][] = $value;
         } else {
             $data[$key] = $value;
         }
     }
     return $data;
 }
开发者ID:rooster,项目名称:symfony,代码行数:40,代码来源:XmlEncoder.php

示例3: getTitle

 /**
  * Returns the form title from the h:title element
  *
  * @return string
  */
 public function getTitle()
 {
     if (empty($this->title)) {
         $this->title = $this->_xml->children('h', true)->head->children('h', true)->title;
     }
     return $this->title;
 }
开发者ID:GemsTracker,项目名称:gemstracker-library,代码行数:12,代码来源:Form.php

示例4: SimpleXmlElement

 function set_search_results($search_entry)
 {
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, 'http://api.bing.net/xml.aspx?AppId=753288BB83E89E80D75157ACE521DB923766F77B&Verstion=2.2&Market=en-US&Query=' . $search_entry->input_user_query . '&Sources=web+spell&web.count=' . TOTAL_SEARCH_NO . '&xmltype=elementbased');
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     $ret = curl_exec($ch);
     curl_close($ch);
     $xml_object = new SimpleXmlElement($ret);
     $children = $xml_object->children('http://schemas.microsoft.com/LiveSearch/2008/04/XML/web');
     $counter = 0;
     foreach ($children->Web->Results->WebResult as $node) {
         $this->array_of_results[$counter]->title = $node->Title;
         $this->array_of_results[$counter]->description = $node->Description;
         $this->array_of_results[$counter]->url = $node->Url;
         $this->array_of_results[$counter]->display_url = $node->DisplayUrl;
         $counter++;
     }
 }
开发者ID:soitun,项目名称:C30440_SoftwareProjectDandySearch,代码行数:18,代码来源:model.php

示例5: executeQuery

 /**
  * @param string $query
  *
  * @return array
  */
 protected function executeQuery($query)
 {
     $content = $this->getAdapter()->getContent($query);
     try {
         $xml = new \SimpleXmlElement($content);
     } catch (\Exception $e) {
         throw new NoResultException(sprintf('Could not execute query %s', $query));
     }
     $dataNode = $xml->children('gml', true)->featureMember->children('', true)->Hostip;
     if (isset($dataNode->ipLocation)) {
         $lngLat = explode(',', (string) $dataNode->ipLocation->children('gml', true)->pointProperty->Point->coordinates);
     } else {
         $lngLat = array(null, null);
     }
     $city = (string) $dataNode->children('gml', true)->name;
     $country = (string) $dataNode->countryName;
     $countryCode = (string) $dataNode->countryAbbrev;
     return array_merge($this->getDefaults(), array('latitude' => $lngLat[1], 'longitude' => $lngLat[0], 'city' => $city, 'country' => $country, 'countryCode' => $countryCode));
 }
开发者ID:socloz,项目名称:geocoder,代码行数:24,代码来源:HostIpProvider.php

示例6: parseXml

 /**
  * Parse the input SimpleXmlElement into an array
  *
  * @param SimpleXmlElement $node xml to parse
  * @return array
  */
 protected function parseXml($node)
 {
     $data = array();
     foreach ($node->children() as $key => $subnode) {
         if ($subnode->count()) {
             $value = $this->parseXml($subnode);
         } else {
             $value = (string) $subnode;
         }
         if ($key === 'item') {
             if (isset($subnode['key'])) {
                 $data[(string) $subnode['key']] = $value;
             } elseif (isset($data['item'])) {
                 $tmp = $data['item'];
                 unset($data['item']);
                 $data[] = $tmp;
                 $data[] = $value;
             }
         } else {
             $data[$key] = $value;
         }
     }
     return $data;
 }
开发者ID:rosstuck,项目名称:Pok,代码行数:30,代码来源:XmlEncoder.php

示例7: parseXml

 /**
  * Parse the input SimpleXmlElement into an array.
  *
  * @param SimpleXmlElement $node xml to parse
  *
  * @return array
  */
 private function parseXml($node)
 {
     $data = array();
     if ($node->attributes()) {
         foreach ($node->attributes() as $attrkey => $attr) {
             $data['@' . $attrkey] = (string) $attr;
         }
     }
     foreach ($node->children() as $key => $subnode) {
         if ($subnode->count()) {
             $value = $this->parseXml($subnode);
         } elseif ($subnode->attributes()) {
             $value = array();
             foreach ($subnode->attributes() as $attrkey => $attr) {
                 $value['@' . $attrkey] = (string) $attr;
             }
             $value['#'] = (string) $subnode;
         } else {
             $value = (string) $subnode;
         }
         if ($key === 'item') {
             if (isset($value['@key'])) {
                 if (isset($value['#'])) {
                     $data[(string) $value['@key']] = $value['#'];
                 } else {
                     $data[(string) $value['@key']] = $value;
                 }
             } else {
                 $data['item'][] = $value;
             }
         } elseif (array_key_exists($key, $data) || $key == "entry") {
             if (false === is_array($data[$key]) || false === isset($data[$key][0])) {
                 $data[$key] = array($data[$key]);
             }
             $data[$key][] = $value;
         } else {
             $data[$key] = $value;
         }
     }
     return $data;
 }
开发者ID:Viduc,项目名称:tiremoidlaold,代码行数:48,代码来源:XmlEncoder.php

示例8: _has_data_children

 /**
  * Checks if a <...> node has <data> children
  *
  * @param  SimpleXmlElement  $field
  * @return boolean             TRUE if at least one child is <data>, FALSE otherwise
  */
 protected function _has_data_children($field)
 {
     $dataChilds = count($field->children()) > 0;
     if ($dataChilds) {
         $dataChilds = false;
         foreach ($field->children() as $child) {
             /** @var $child SimpleXmlElement */
             if ($child->getName() == 'data') {
                 $dataChilds = true;
                 break;
             }
         }
     }
     return $dataChilds;
 }
开发者ID:Raul-mz,项目名称:web-erpcya,代码行数:21,代码来源:XmlQuery.php

示例9: LoadAdvisor

 public function LoadAdvisor($_IDIntern, $_BaliseName)
 {
     $extension = null;
     //extension
     if ($_BaliseName == "cieReview") {
         $extension = '_CieEVL.xml';
     }
     if ($_BaliseName == "review1") {
         $extension = '_AdvRev1EVL.xml';
     }
     if ($_BaliseName == "review2") {
         $extension = '_AdvRev2EVL.xml';
     }
     //Déclaration du tableau dans lequelle sera stoqué tous les rapports
     $obj = array();
     //Si le fichier souhaiter existe le charge en mémoire et récupère toute les informations
     if (file_exists(parent::DefaultXMLPath . 'evaluation/' . $_IDIntern . $extension)) {
         $_Simple = new SimpleXmlElement(parent::DefaultXMLPath . 'evaluation/' . $_IDIntern . $extension, 0, true);
         //Pour tout les éléments contenu dans le fichier XML, sous la balise passé en paramètre, l'ajouter dans le tableau $obj
         foreach ($_Simple->children() as $Enfant) {
             if ($Enfant->getName() == $_BaliseName) {
                 foreach ($Enfant->children() as $Info) {
                     $obj[$Info->getName()] = (string) $Info;
                 }
             }
         }
     }
     $Result = new obj($obj);
     //Transforme les journeaux en objet utilisable et les retourne
     return $Result;
 }
开发者ID:gragor3000,项目名称:Projet-Integrateur,代码行数:31,代码来源:docs.php

示例10: _decodeParam

 /**
 	Convert an XML-RPC value element to a PHP value
 
 	Parameters:
 		param - (SimpleXmlElement) XML element containing the XML-RPC 'value' node
 
 	Returns:
 		(mixed) The PHP value
 */
 protected function _decodeParam(SimpleXmlElement $param)
 {
     $children = $param->children();
     $child = $children[0];
     switch ($child->getName()) {
         case 'struct':
             $values = array();
             foreach ($child->member as $member) {
                 $values[(string) $member->name] = $this->_decodeParam($member->value);
             }
             return $values;
         case 'array':
             $values = array();
             foreach ($child->data->value as $value) {
                 $values[] = $this->_decodeParam($value);
             }
             return $values;
         case 'nil':
             return null;
         case 'i4':
         case 'int':
             return (int) $child;
         case 'double':
             return (double) $child;
         case 'boolean':
             // $child is an object SimpleXmlElement which will 'toString' to '0' / '1', which boolean casts properly
             return (bool) (string) $child;
         case 'base64':
         case 'dateTime.iso8601':
         case 'string':
             return (string) $child;
         default:
             throw new OpenReact_XmlRpc_Client_UnsupportedXmlRpcValueTypeException('Unsupported XML-RPC value type `%s` found.', array($child->getName()));
     }
 }
开发者ID:Bouwdie,项目名称:OpenReact_XmlRpc_Client,代码行数:44,代码来源:Client.php

示例11: parseSegmentGroup

 /**
  * Parse an edifact segment group and return the correponding
  * EDI_EDIFACT_SegmentGroup object.
  *
  * @param string           $id      Id of the segment group (SG1, SG2...)
  * @param array            &$data   Array of CDE or data elements
  * @param SimpleXmlElement $mapping Corresponding mapping node
  * @param bool             $req     set this to false if the CDE is optional
  *
  * @access protected
  * @return EDI_EDIFACT_SegmentGroup
  * @throws EDI_Exception
  */
 protected function parseSegmentGroup($id, &$data, $mapping, $req = true)
 {
     if ($req && empty($data)) {
         throw new EDI_Exception("segment group \"{$id}\" is required.", EDI_Exception::E_EDI_SYNTAX_ERROR);
     }
     $elt = new EDI_EDIFACT_SegmentGroup();
     $children = $mapping->children();
     $hasChildren = false;
     foreach ($children as $node) {
         $nodeName = (string) $node->getName();
         $nodeId = (string) $node['id'];
         $nodeReq = (string) $node['required'] == 'true';
         $nodeMaxRepeat = (int) $node['maxrepeat'];
         if ($nodeName == 'segment') {
             if (empty($data)) {
                 if ($req && $nodeReq) {
                     throw new EDI_Exception(sprintf('segment "%s" is required in group "%s"', $nodeId, $id), EDI_Exception::E_EDI_SYNTAX_ERROR);
                 }
                 break;
             }
             list($sId, $sData) = $data[0];
             if ($sId != $nodeId) {
                 if ($req && $nodeReq) {
                     throw new EDI_Exception(sprintf('segment "%s" is required in group "%s"', $nodeId, $id), EDI_Exception::E_EDI_SYNTAX_ERROR);
                 } else {
                     if ($nodeReq) {
                         // we can skip this group...
                         break;
                     }
                 }
                 continue;
             }
             if ($nodeMaxRepeat > 1) {
                 $e = $this->parseSegmentRepetition($sId, $data, $nodeMaxRepeat, $nodeReq);
             } else {
                 $e = $this->parseSegment($sId, $data, $nodeReq);
             }
         } else {
             if ($nodeName == 'group') {
                 if ($nodeMaxRepeat > 1) {
                     $e = $this->parseSegmentGroupRepetition($nodeId, $data, $node, $nodeMaxRepeat, $nodeReq);
                 } else {
                     $e = $this->parseSegmentGroup($nodeId, $data, $node, $nodeReq);
                 }
             }
         }
         if ($e !== null) {
             $elt[] = $e;
             $hasChildren = true;
         }
     }
     $elt->id = $id . '_group';
     return $hasChildren ? $elt : null;
 }
开发者ID:sutt0n,项目名称:php_edifact,代码行数:67,代码来源:Parser.php

示例12: _getLogMessagesArr

 /**
  * Get a list of all builds of a project
  *
  * @param string $projectName
  * @param integer $start
  * @param integer $limit
  *
  * @return stdClass
  */
 private function _getLogMessagesArr($projectName, $buildTime, $start, $limit = null)
 {
     $statusDir = Xinc_Gui_Handler::getInstance()->getStatusDir();
     $historyFile = $statusDir . DIRECTORY_SEPARATOR . $projectName . '.history';
     $project = new Xinc_Project();
     $project->setName($projectName);
     $totalCount = 0;
     try {
         $build = Xinc_Build::unserialize($project, $buildTime, $statusDir);
         $timezone = $build->getConfigDirective('timezone');
         if ($timezone !== null) {
             Xinc_Timezone::set($timezone);
         }
         $detailDir = Xinc_Build_History::getBuildDir($project, $buildTime);
         $logXmlFile = $detailDir . DIRECTORY_SEPARATOR . 'buildlog.xml';
         if (file_exists($logXmlFile)) {
             /**
              * Add fopen() to the function to just get the loglines
              * that we need.
              * the bigger the logfiles get, the more this gets a
              * performance problem
              */
             $xmlStr = '';
             $pos = 0;
             $fh = fopen($logXmlFile, 'r');
             $xmlStr = fgets($fh);
             $xmlStr .= fgets($fh);
             $tagOpen = false;
             while ($pos < $start && ($message = $this->_getNextMessage($fh)) !== false) {
                 $pos++;
                 $totalCount++;
             }
             if ($limit != null) {
                 $addClosingTag = true;
                 while ($pos < $start + $limit && ($message = $this->_getNextMessage($fh)) !== false) {
                     $xmlStr .= $message;
                     $pos++;
                     $totalCount++;
                 }
                 $xmlStr .= '</build>';
             } else {
                 while (($message = $this->_getNextMessage($fh)) !== false) {
                     $xmlStr .= $message;
                     $totalCount++;
                     $pos++;
                 }
                 $xmlStr .= '</build>';
             }
             $tagOpen = false;
             $tagClosed = false;
             while (($message = $this->_getNextMessage($fh)) !== false) {
                 $totalCount++;
                 $pos++;
             }
             fclose($fh);
             $logXml = new SimpleXMLElement($xmlStr);
         } else {
             $logXml = new SimpleXmlElement('<log/>');
         }
         $totalCount = $pos;
         //count($logXml->children());
         $i = $pos;
         $logmessages = array();
         $id = $totalCount - $start;
         foreach ($logXml->children() as $logEntry) {
             $attributes = $logEntry->attributes();
             $logmessages[] = array('id' => $id--, 'date' => (string) $attributes->timestamp, 'stringdate' => date('Y-m-d H:i:s', (int) $attributes->timestamp), 'timezone' => Xinc_Timezone::get(), 'priority' => (string) $attributes->priority, 'message' => base64_decode($logEntry));
         }
         /**
          * restore to system timezone
          */
         $xincTimezone = Xinc_Gui_Handler::getInstance()->getConfigDirective('timezone');
         if ($xincTimezone !== null) {
             Xinc_Timezone::set($xincTimezone);
         } else {
             Xinc_Timezone::reset();
         }
         //$logmessages = array_slice($logmessages, $start, $limit, false);
     } catch (Exception $e1) {
         $totalCount = 0;
         $logmessages = array();
     }
     $object = new stdClass();
     $object->totalmessages = $totalCount;
     $object->logmessages = $logmessages;
     //return new Xinc_Build_Iterator($builds);
     return $object;
 }
开发者ID:google-code-backups,项目名称:xinc,代码行数:97,代码来源:LogMessages.php

示例13: _loadXML

 private function _loadXML()
 {
     $feed = file_get_contents($this->_query_link);
     $xml = new SimpleXmlElement($feed);
     //Use that namespace
     $namespaces = $xml->getNameSpaces(true);
     //Now we don't have the URL hard-coded
     $dc = (array) $xml->children($namespaces['dc']);
     //load data to $this->this results
     foreach ($dc as $key => $value) {
         switch ($key) {
             case 'creator':
                 $this->_fetchAuthors($value);
                 break;
             case 'identifier':
                 $this->_fetchIds($value);
                 break;
             case 'title':
                 $this->_fetchTitle($value);
                 break;
             case 'publisher':
                 $this->_fetchPublisher($value);
                 break;
             case 'language':
                 $this->_fetchLanguage($value);
                 break;
             case 'description':
                 $this->_fetchDescription($value);
                 break;
             case 'subject':
                 $this->_fetchSubject($value);
                 break;
             case 'format':
                 $this->_fetchFormat($value);
                 break;
         }
     }
 }
开发者ID:eldorplus,项目名称:isbn_search,代码行数:38,代码来源:google_query.php

示例14: array

        /* Run request on twitter API as user. */
        $content = $to->OAuthRequest('https://twitter.com/account/verify_credentials.xml', array(), 'GET');
        //$content = $to->OAuthRequest('https://twitter.com/statuses/update.xml', array('status' => 'twitter'), 'POST');
        //$content = $to->OAuthRequest('https://twitter.com/statuses/replies.xml', array(), 'POST');
        break;
}
?>

<?php 
if (!isset($_GET["oauth_token"])) {
    echo $content;
} else {
    //response from twitter
    $aa = array();
    $xml = new SimpleXmlElement($content);
    foreach ($xml->children() as $val) {
        $aa[] = $val;
    }
    //print_r($aa); exit;
    $username = "TW" . $aa[0];
    $firstname = $aa[1];
    $img_url = $aa[5];
    //add the twitter information
    if ($_SESSION["userrole"] == 1) {
        updateTWuser($_SESSION['oauth_access_token'], $_SESSION['oauth_access_token_secret'], $tok["user_id"], $firstname);
        url_redirect(DOCROOT . "admin/social-media-account/");
    }
    //login function
    easyRegister($username, $firstname, "", "", $img_url, 2);
    /*
    	$content1=$to->OAuthRequest('http://twitter.com/statuses/friends.xml?user_id='.$aa[0], array(), 'GET');
开发者ID:AdoSalkic,项目名称:personal,代码行数:31,代码来源:index.php


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