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


PHP SimpleXMLElement::AddChild方法代码示例

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


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

示例1: array

        $l_aReturn = array_merge($l_aReturn, $temp);
        $temp = array();
    }
}
if ($id != 0) {
    $allResults = $sph->multiSearch();
    for ($i = 0; $i < sizeof($allResults); $i++) {
        $l_iTotalFound = $sph->getTotalFound($i);
        $temp[$i]['count'] = $l_iTotalFound;
        unset($temp[$i]['lat']);
        unset($temp[$i]['lng']);
        unset($temp[$i]['radius']);
    }
    $l_aReturn = array_merge($l_aReturn, $temp);
}
if (!empty($l_aReturn)) {
    $l_sXMLbase = '<?xml version="1.0" encoding="UTF-8"?><Regions></Regions>';
    $l_sFilename = "/home/eyezeek/netup/ru/seo/regions_" . $l_sSection . "_data.xml";
    echo "Saving to XML file {$l_sFilename}...\n";
    $l_oXML = new SimpleXMLElement($l_sXMLbase);
    foreach ($l_aReturn as $region) {
        $l_nodePartner = $l_oXML->AddChild('Region');
        $l_nodePartner->AddChild('name', $region['name']);
        $l_nodePartner->AddChild('icon', $region['icon']);
        $l_nodePartner->AddChild('count', $region['count']);
        $l_nodePartner->AddChild('translit', $region['translit']);
    }
    file_put_contents($l_sFilename, $l_oXML->asXML());
    unset($l_oXML);
    $l_oXML = NULL;
}
开发者ID:sergrin,项目名称:crawlers-il,代码行数:31,代码来源:buildRUGeoRegionsXML.php

示例2: translit

        $sph->setOptions($options);
        $res = $sph->search();
        if ($res) {
            array_unshift($l_aXmlData, array('count' => $res['total_found'], 'name' => 'Московская область', 'translit' => 'moskovskaya-oblast'));
        }
    }
    /**
     *  Creating XML
     */
    if (!empty($l_aXmlData)) {
        $l_sXMLbase = '<?xml version="1.0" encoding="UTF-8"?><TopFortyCities></TopFortyCities>';
        $l_sFilename = "/home/eyezeek/netup/ru/seo/top_forty_cities_" . $l_sSection . "_data.xml";
        echo "Saving to XML file {$l_sFilename}...\n";
        $l_oXML = new SimpleXMLElement($l_sXMLbase);
        foreach ($l_aXmlData as $city) {
            $l_nodePartner = $l_oXML->AddChild('City');
            $l_nodePartner->AddChild('name', $city['name']);
            $l_nodePartner->AddChild('count', $city['count']);
            $l_nodePartner->AddChild('translit', $city['translit']);
        }
        file_put_contents($l_sFilename, $l_oXML->asXML());
        unset($l_oXML);
        $l_oXML = NULL;
        echo "\nCompleted.\n";
    }
}
function translit($origin, $link)
{
    $sql = "SELECT origin,translit\n\t\t\tFROM translitted_values t\n\t\t\tWHERE origin='{$origin}'";
    //echo"\n$sql\n";
    $res = mysqli_query($link, $sql);
开发者ID:sergrin,项目名称:crawlers-il,代码行数:31,代码来源:build_top_forty_cities_xml.php

示例3: __construct

    public $port;
    public function __construct($port)
    {
        $this->port = $port;
    }
}
$sph = new CSphinx(new sph_conf('3313'));
$options = array('connectTimeout' => 5, 'arrayResult' => TRUE, 'matchMode' => SPH_MATCH_EXTENDED2, 'index' => 'i_ref_vehicles i_delta_vehicles', 'page' => 1, 'limit' => 1);
$l_sSection = 'vehicles';
$sph->resetSphinx();
$options['groupBy'] = array('l_www_id', SPH_GROUPBY_ATTR);
$sph->setAttribute('www_site_type', '2');
$sph->setAttribute('what', $l_sSection);
$sph->setFilter($sph->VALUE_FILTER, array('alps_promoted', array(1), FALSE));
$sph->setOptions($options);
$result = $sph->search(NULL, FALSE);
foreach ($result['matches'] as $one_promoted_dealer) {
    $l_aReturnIDs[] = $one_promoted_dealer['attrs']['l_www_id'];
}
if (!empty($result)) {
    $l_sXMLbase = '<?xml version="1.0" encoding="UTF-8"?><Default_top_dealers></Default_top_dealers>';
    $l_sFile_name = "/home/eyezeek/netup/ru/seo/" . $l_sSection . "_default_top_dealers.xml";
    $l_oXML = new SimpleXMLElement($l_sXMLbase);
    foreach ($l_aReturnIDs as $dealer) {
        $l_node = $l_oXML->AddChild('dealer');
        $l_node->AddChild('id', $dealer);
    }
    file_put_contents($l_sFile_name, $l_oXML->asXML());
    unset($l_oXML);
    $l_oXML = NULL;
}
开发者ID:sergrin,项目名称:crawlers-il,代码行数:31,代码来源:build_default_top_dealers_xml.php

示例4: array

$tmp_arr = array();
for ($i = 0; $i < count($cities); $i++) {
    $sph->setAttribute('what', $l_sSection);
    //don't filter for all Russia
    if ($i > 0) {
        $sph->setAttribute('llocationcity,', $cities[$i]['city_name']);
    }
    $sph->setOptions($options);
    $cities[$i]['count'] = $sph->addQuery();
}
$allResults = $sph->multiSearch();
for ($i = 0; $i < sizeof($allResults); $i++) {
    $l_iTotalFound = $sph->getTotalFound($i);
    $cities[$i]['count'] = $l_iTotalFound;
}
$result = $cities;
if (!empty($result)) {
    $l_sXMLbase = '<?xml version="1.0" encoding="UTF-8"?><Top_cities_jobs></Top_cities_jobs>';
    $l_sFilecity_name = "/home/eyezeek/netup/ru/seo/top_cities_" . $l_sSection . ".xml";
    $l_oXML = new SimpleXMLElement($l_sXMLbase);
    echo "Saving to XML file {$l_sFilecity_name}...\n";
    foreach ($result as $city) {
        $l_nodeCity = $l_oXML->AddChild('City');
        $l_nodeCity->AddChild('city_name', $city['city_name']);
        $l_nodeCity->AddChild('city_icon', $city['city_icon']);
        $l_nodeCity->AddChild('count', $city['count']);
    }
}
file_put_contents($l_sFilecity_name, $l_oXML->asXML());
unset($l_oXML);
$l_oXML = NULL;
开发者ID:sergrin,项目名称:crawlers-il,代码行数:31,代码来源:build_geo_top_cities_xml.php

示例5: exportXml


//.........这里部分代码省略.........
 function exportXml($lng = array(), $invoice_number = '')
 {
     if ($this->userId == 0 || !is_array($this->user) || empty($this->user) || $this->user[getModeDetails($this->mode, 'TABLE_PANEL_USERS', 'key')] != $this->userId) {
         return false;
     }
     $invoice = $this->exportArray($lng);
     $invoiceXml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><invoice></invoice>');
     $invoiceXml->addChild('invoice_number', utf8_encode(htmlspecialchars($invoice_number)));
     $invoiceXml->addChild('invoice_date', makeNicePresentableDate(date('Y-m-d'), $lng['panel']['dateformat_function']));
     $address = $invoiceXml->addChild('address');
     $address->addChild('name', utf8_encode(htmlspecialchars($this->user['name'])));
     $address->addChild('firstname', utf8_encode(htmlspecialchars($this->user['firstname'])));
     $address->addChild('title', utf8_encode(htmlspecialchars($this->user['title'])));
     $address->addChild('company', utf8_encode(htmlspecialchars($this->user['company'])));
     $address->addChild('street', utf8_encode(htmlspecialchars($this->user['street'])));
     $address->addChild('zipcode', utf8_encode(htmlspecialchars($this->user['zipcode'])));
     $address->addChild('city', utf8_encode(htmlspecialchars($this->user['city'])));
     $address->addChild('country', utf8_encode(htmlspecialchars($this->user['country'])));
     $billing = $invoiceXml->addChild('billing');
     $billing->addChild('contract_number', utf8_encode(htmlspecialchars($this->user['contract_number'])));
     $billing->addChild('contract_details', utf8_encode(htmlspecialchars(sprintf(html_entity_decode($lng['invoice']['contract_details_template']), makeNicePresentableDate($this->user['contract_date'], $lng['panel']['dateformat_function']), (int) $this->user['diskspace'] / 1024 == '-1' ? html_entity_decode($lng['customer']['unlimited']) : (string) round((int) $this->user['diskspace'] / 1024, 2), $this->user['additional_diskspace_fee'], (string) round((int) $this->user['additional_diskspace_unit'] / 1024, 4), (int) $this->user['traffic'] / (1024 * 1024) == '-1' ? html_entity_decode($lng['customer']['unlimited']) : (string) round((int) $this->user['traffic'] / (1024 * 1024), 4), $this->user['additional_traffic_fee'], (string) round((int) $this->user['additional_traffic_unit'] / (1024 * 1024), 4), $this->user['included_domains_qty'], $this->user['interval_fee'], str_replace('1 ' . $lng['panel']['intervalfee_type'][$this->user['interval_type']], $lng['panel']['intervalfee_type_one'][$this->user['interval_type']], $this->user['interval_length'] . ' ' . $lng['panel']['intervalfee_type'][$this->user['interval_type']]), str_replace('1 ' . $lng['panel']['intervalfee_type'][$this->user['interval_type']], '1 ' . $lng['panel']['intervalfee_type_one'][$this->user['interval_type']], (string) ((int) $this->user['interval_length'] * (int) $this->user['payment_every']) . ' ' . $lng['panel']['intervalfee_type'][$this->user['interval_type']])))));
     $billing->addChild('payment_method', utf8_encode(htmlspecialchars($this->user['payment_method'])));
     $billing->addChild('term_of_payment', utf8_encode(htmlspecialchars($this->user['term_of_payment'])));
     $billing->addChild('bankaccount_holder', utf8_encode(htmlspecialchars($this->user['bankaccount_holder'])));
     $billing->addChild('bankaccount_number', utf8_encode(htmlspecialchars($this->user['bankaccount_number'])));
     $billing->addChild('bankaccount_blz', utf8_encode(htmlspecialchars($this->user['bankaccount_blz'])));
     $billing->addChild('bankaccount_bank', utf8_encode(htmlspecialchars($this->user['bankaccount_bank'])));
     $billing->addChild('taxid', utf8_encode(htmlspecialchars($this->user['taxid'])));
     $billing->addChild('calc_tax', utf8_encode(htmlspecialchars($this->user['calc_tax'])));
     $total_fee = 0;
     $total_fee_taxed = 0;
     $tax = array();
     $allservices_begin = 0;
     $allservices_end = 0;
     foreach ($invoice as $service_type => $service_details) {
         $service_category = $invoiceXml->addChild('service_category');
         $service_category->addAttribute('service_type', utf8_encode(htmlspecialchars($service_type)));
         $service_category->addChild('caption', utf8_encode(htmlspecialchars(html_entity_decode($service_details['caption']))));
         $service_category->addChild('interval', utf8_encode(htmlspecialchars(html_entity_decode($service_details['interval']))));
         if (calculateDayDifference($service_details['service_date_begin'], $service_details['service_date_end']) != 0) {
             $invoiceXml->addChild('service_date_begin', utf8_encode(htmlspecialchars($service_details['service_date_begin'])));
             $invoiceXml->addChild('service_date_end', utf8_encode(htmlspecialchars($service_details['service_date_end'])));
         } else {
             $invoiceXml->addChild('service_date', utf8_encode(htmlspecialchars($service_details['service_date_begin'])));
         }
         if (calculateDayDifference($service_details['service_date_begin'], $allservices_begin) > 0 || $allservices_begin == 0) {
             $allservices_begin = $service_details['service_date_begin'];
         }
         if (calculateDayDifference($allservices_end, $service_details['service_date_end']) > 0 || $allservices_end == 0) {
             $allservices_end = $service_details['service_date_end'];
         }
         foreach ($service_details['rows'] as $rowid => $row) {
             $invoice_row = $service_category->addChild('invoice_row');
             $invoice_row->addAttribute('key', utf8_encode(htmlspecialchars($row['key'])));
             $invoice_row->addChild('service_occurence', utf8_encode(htmlspecialchars($row['service_occurence'])));
             switch ($row['service_occurence']) {
                 case 'once':
                     $invoice_row->addAttribute('date', utf8_encode(htmlspecialchars(makeNicePresentableDate($row['service_date'], 'Ymd'))));
                     $invoice_row->addChild('service_date', utf8_encode(htmlspecialchars($row['service_date'])));
                     break;
                 case 'period':
                     $invoice_row->addAttribute('date', utf8_encode(htmlspecialchars(makeNicePresentableDate($row['service_date_begin'], 'Ymd'))));
                     $invoice_row->addChild('service_date_begin', utf8_encode(htmlspecialchars($row['service_date_begin'])));
                     $invoice_row->addChild('service_date_end', utf8_encode(htmlspecialchars($row['service_date_end'])));
                     break;
             }
             $invoice_row->addChild('caption', utf8_encode(htmlspecialchars(html_entity_decode($row['description']['caption']))));
             $invoice_row->addChild('interval', utf8_encode(htmlspecialchars($row['interval'])));
             $invoice_row->addChild('quantity', utf8_encode(htmlspecialchars($row['quantity'])));
             $invoice_row->addChild('single_fee', utf8_encode(htmlspecialchars($row['single_fee'])));
             $invoice_row->addChild('total_fee', utf8_encode(htmlspecialchars($row['total_fee'])));
             $invoice_row->addChild('taxrate', utf8_encode(htmlspecialchars($row['taxrate'])));
             $invoice_row->addChild('tax', utf8_encode(htmlspecialchars($row['tax'])));
             $invoice_row->addChild('total_fee_taxed', utf8_encode(htmlspecialchars($row['total_fee_taxed'])));
             if (!isset($tax[$row['taxrate']])) {
                 $tax[$row['taxrate']] = 0;
             }
             $tax[$row['taxrate']] += $row['tax'];
             $total_fee += $row['total_fee'];
             $total_fee_taxed += $row['total_fee_taxed'];
         }
     }
     if (calculateDayDifference($allservices_begin, $allservices_end) != 0) {
         $invoiceXml->addChild('invoice_period', utf8_encode(htmlspecialchars(makeNicePresentableDate($allservices_begin, $lng['panel']['dateformat_function']) . ' - ' . makeNicePresentableDate($allservices_end, $lng['panel']['dateformat_function']))));
     } else {
         $invoiceXml->addChild('invoice_period', utf8_encode(htmlspecialchars(makeNicePresentableDate($allservices_begin, $lng['panel']['dateformat_function']))));
     }
     $credit_note = $this->getCreditNote();
     if ($credit_note != 0) {
         $invoiceXml->addChild('credit_note', utf8_encode(htmlspecialchars(sprintf("%01.2f", $credit_note))));
         $total_fee_taxed -= $credit_note;
     }
     $invoiceXml->addChild('total_fee', utf8_encode(htmlspecialchars(sprintf("%01.2f", $total_fee))));
     foreach ($tax as $taxrate => $taxamount) {
         $taxXml = $invoiceXml->AddChild('tax', utf8_encode(htmlspecialchars(sprintf("%01.2f", $taxamount))));
         $taxXml->addAttribute('taxrate', utf8_encode(htmlspecialchars($taxrate)));
     }
     $invoiceXml->addChild('total_fee_taxed', utf8_encode(htmlspecialchars(sprintf("%01.2f", $total_fee_taxed))));
     return $invoiceXml->asXML();
 }
开发者ID:markc,项目名称:syscp,代码行数:101,代码来源:class.invoice.php


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