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


PHP xml::children方法代码示例

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


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

示例1: cpanel_ddns_SearchForHostInZoneFile

/**
 * Search for a host in the DNS Zone file and return the details in an array
 *
 * @param xml $zoneXML
 * @param string $host
 * @return array
 */
function cpanel_ddns_SearchForHostInZoneFile($zoneXML, $host)
{
    // Count the number of zone records
    $dns_records_count = count($zoneXML->children());
    // PHP < 5.3 version
    /*
     * Loop though the zone records until we find the one that contains the record 
     * we wish to update. Also locate the SOA record if exists.
     */
    for ($i = 0; $i <= $dns_records_count; $i++) {
        // Search for the record we want to update
        if ($zoneXML->record[$i]->name == $host . '.' && $zoneXML->record[$i]->type == 'A') {
            $zone_number_to_update = $i;
        }
        // Look for the SOA record
        if ($zoneXML->record[$i]->type == 'SOA') {
            $zone_number_of_SOA_record = $i;
        }
    }
    /*
     * Check if we were able to locate an SOA record and return the serial if so
     */
    if (!is_null($zone_number_of_SOA_record)) {
        // We were able to locate an SOA record
        $SOA_record = cpanel_ddns_FetchRecordFromXMLByNumber($zoneXML, $zone_number_of_SOA_record);
        //        echo ' % ' . $SOA_record['serial'] . ' % ';
    } else {
        // We were not able to locate an SOA record for this domain.
        cpanel_ddns_ErrorMessageAdd('SOA not found for this domain.');
        return FALSE;
    }
    /*
     * Were we able to locate the host record?
     */
    if (!is_null($zone_number_to_update)) {
        // We were able to locate an A record
        $zone_record = cpanel_ddns_FetchRecordFromXMLByNumber($zoneXML, $zone_number_to_update);
        //        echo ' % ' . $zone_record['name'] . ' % ';
    } else {
        // We were not able to locate an A record for this host.
        cpanel_ddns_ErrorMessageAdd('A record was not found for this host.');
        return FALSE;
    }
    return $zone_record;
}
开发者ID:netluxe,项目名称:cpanel_ddns,代码行数:52,代码来源:functions.php

示例2: wpgmp_xml_2array

 /**
  * Convert xml node to array.
  * @param  xml $xml Xml file content object.
  * @return array      array of xml data.
  */
 public function wpgmp_xml_2array($xml)
 {
     $arr = array();
     foreach ($xml->children() as $r) {
         $t = array();
         if (count($r->children()) == 0) {
             $arr[$r->getName()] = strval($r);
         } else {
             $arr[$r->getName()][] = $this->wpgmp_xml_2array($r);
         }
     }
     return $arr;
 }
开发者ID:OpenDoorBrewCo,项目名称:odbc-wp-prod,代码行数:18,代码来源:class.importer.php


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