本文整理汇总了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;
}
示例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;
}