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


PHP SimpleXMLElement::addchild方法代码示例

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


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

示例1: buildRequestHeader

 function buildRequestHeader($requestParams)
 {
     $session = new SimpleXMLElement('<session></session>');
     $sessionId = $session->addchild('id');
     $clec = $session->addchild('clec');
     $clec->addchild('overrides');
     $id = $clec->addchild('id');
     $id[0] = $requestParams->id;
     $user = $clec->addchild('user');
     $firstName = $user->addChild('firstName');
     $firstName[0] = $requestParams->firstName;
     $lastName = $user->addChild('lastName');
     $lastName[0] = $requestParams->lastName;
     return $session;
 }
开发者ID:jamessun,项目名称:assist-portal,代码行数:15,代码来源:api_backup.php

示例2: encode_arg

 /**
  * Encode a variable value into the parameters of the XML tree
  *
  * @param SimpleXMLElement $params The parameter to add the value elements to.
  * @param mixed $arg The value to encode
  */
 public static function encode_arg($params, $arg)
 {
     switch (true) {
         case is_array($arg):
             $data = $params->addchild('value')->addchild('array')->addchild('data');
             foreach ($arg as $element) {
                 self::encode_arg($data, $element);
             }
             break;
         case $arg instanceof XMLRPCDate:
             $params->addchild('value')->addchild('dateTime.iso8601', date('c', $arg->date));
             break;
         case $arg instanceof XMLRPCBinary:
             $params->addchild('value')->addchild('base64', base64_encode($arg->data));
             break;
         case $arg instanceof XMLRPCStruct:
             $struct = $params->addchild('value')->addchild('struct');
             $object_vars = $arg->get_fields();
             foreach ($object_vars as $field) {
                 $member = $struct->addchild('member');
                 $member->addchild('name', $field);
                 self::encode_arg($member, $arg->{$field});
             }
             break;
         case is_object($arg):
             $struct = $params->addchild('value')->addchild('struct');
             $object_vars = get_object_vars($arg);
             foreach ($object_vars as $key => $value) {
                 $member = $struct->addchild('member');
                 $member->addchild('name', $key);
                 self::encode_arg($member, $value);
             }
             break;
         case is_integer($arg):
             $params->addchild('value')->addchild('i4', $arg);
             break;
         case is_bool($arg):
             $params->addchild('value')->addchild('boolean', $arg ? '1' : '0');
             break;
         case is_string($arg):
             $params->addchild('value')->addchild('string', $arg);
             break;
         case is_float($arg):
             $params->addchild('value')->addchild('double', $arg);
             break;
     }
 }
开发者ID:anupom,项目名称:my-blog,代码行数:53,代码来源:xmlrpcutils.php

示例3: __call

 /**
  * Allow method overloading for this class.
  * This method allows any method name to be called on this object.  The method
  * called is the method called via RPC, within the scope defined in $this->scope.
  *
  * @param string $fname The function name to call
  * @param array $args An array of arguments that were called with the function
  * @return array The result array
  */
 public function __call($fname, $args)
 {
     if ($this->scope != '') {
         $rpc_method = "{$this->scope}.{$fname}";
     } else {
         $rpc_method = $fname;
     }
     $rpx = new SimpleXMLElement('<methodCall/>');
     $rpx->addChild('methodName', $rpc_method);
     if (count($args) > 0) {
         $params = $rpx->addchild('params');
         foreach ($args as $arg) {
             $param = $params->addchild('param');
             XMLRPCUtils::encode_arg($param, $arg);
         }
     }
     $request = new RemoteRequest($this->entrypoint, 'POST');
     $request->add_header('Content-Type: text/xml;charset=utf-8');
     $request->set_body($rpx->asXML());
     $request->execute();
     if ($request->executed()) {
         $response = $request->get_response_body();
         // @todo this should use the MultiByte class, not directly call mb_string functions
         $enc = mb_detect_encoding($response);
         $responseutf8 = mb_convert_encoding($response, 'UTF-8', $enc);
         try {
             // @todo this should use libxml_use_internal_errors() instead of trying to hide the PHP warning see the plugin info parsing code for an example
             $bit = ini_get('error_reporting');
             error_reporting($bit && !E_WARNING);
             $responsexml = new SimpleXMLElement($responseutf8);
             error_reporting($bit);
             $tmp = $responsexml->xpath('//params/param/value');
             if (!($responsestruct = reset($tmp))) {
                 $tmp = $responsexml->xpath('//fault/value');
                 if (!($responsestruct = reset($tmp))) {
                     throw new Exception(_t('Invalid XML response.'));
                 }
             }
             return XMLRPCUtils::decode_args($responsestruct);
         } catch (Exception $e) {
             //Utils::debug( $response, $e );
             error_reporting($bit);
             return false;
         }
     }
 }
开发者ID:wwxgitcat,项目名称:habari,代码行数:55,代码来源:xmlrpcclient.php

示例4: actionIndex

 public function actionIndex()
 {
     // 		$arrGoogle=array('google','Gmail','Chrome','Android');
     // //第一次使用each取得当前键值对,并且将指针移到下一个位置
     // $arrG=each($arrGoogle);
     // print_r($arrG);
     // $arrGmail=each($arrGoogle);
     // print_r($arrGmail);
     // $arrChrome=each($arrGoogle);
     // print_r($arrChrome);
     // $arrAndroid=each($arrGoogle);
     // print_r($arrAndroid);
     //当指针位于数组末尾再次执行函数each,如果是这样再次执行结果返回false
     // $empty=each($arrGoogle);die();
     $xml = new SimpleXMLElement('<?xml version="1.0" encoding="GBK"?><DOCUMENT />');
     header("Content-type: text/html; charset=utf-8");
     include "simple_html_dom.php";
     $html = file_get_html('http://www.ttpet.com/quanzhong/jinmao.html');
     $item = $xml->addchild("item");
     // Find all images
     foreach ($html->find('dl.qz_inft ') as $element) {
         /*echo $element;die();*/
         /*echo $element->children(2);echo $element->children(3);die()*/
         // $num1 = $item->addchild("name",$element->children(1)->plaintext);
         $num1 = $item->addchild("alias", $element->children(2)->plaintext);
     }
     $num1 = $item->addchild("ename", $element->children(3)->plaintext);
     // $num1 = $item->addchild("weight",$element->children(8)->plaintext);
     // $num1 = $item->addchild("years",$element->children(9)->plaintext);
     // $num1 = $item->addchild("place",$element->children(10)->plaintext);
     // $num1 = $item->addchild("shape",$element->children(4)->plaintext);
     // $num1 = $item->addchild("wool",$element->children(6)->plaintext);
     $num1 = $item->addchild("function", $element->children(5)->plaintext);
     // $num1 = $item->addchild("name",$element->plaintext);
     // unset($num1);continue;
     // $item->addchild("age",$element-next_sibling()->plaintext();
     header("Content-type: text/xml");
     echo $xml->asXml();
     $xml->asXml("student.xml");
     // die();
 }
开发者ID:ahinap,项目名称:wordpress,代码行数:41,代码来源:LoginController.php

示例5: __toString

 /**
  * Creates the KML code from data given
  *
  * @access public
  * @return string
  */
 public function __toString()
 {
     // Set the xml version
     $xml_head = '<?xml version="1.0" encoding="UTF-8"?>';
     // Open a new KML doc
     $sxe = new SimpleXMLElement('<kml xmlns = "http://earth.google.com/kml/2.1"></kml>');
     // Put document in the kml
     $doc = $sxe->addchild('Document');
     // Set all the styles for the document
     foreach ($this->styles as $s) {
         $style = $doc->addChild('Style');
         $style->addAttribute('id', $s->getId());
         $iconStyle = $style->addChild('IconStyle');
         $iconStyle->addAttribute('id', $s->getIconId());
         $icon = $iconStyle->addChild('Icon');
         $icon->addChild('href', $s->getIconLink());
     }
     // Set all the folders and places in each folder
     foreach ($this->folders as $f => $places) {
         if ($f != '**[root]**') {
             // Set the folder and folder name
             $folder = $doc->addChild('Folder');
             $folder->addChild('name', $f);
             $folder->addChild('open', 0);
             // Set all the placemarks in this folder
             foreach ($places as $p) {
                 // Add all the placemark details
                 $place = $folder->addChild('Placemark');
                 $place->addAttribute('id', $p->getId());
                 $place->addChild('name', $p->getName());
                 $place->addChild('description', $p->getDesc());
                 $place->addChild('styleUrl', $p->getStyle());
                 // Add coordinates information
                 $point = $place->addChild('Point');
                 $point->addChild('coordinates', $p->getCoords());
             }
         }
     }
     // Set all the root placemarks so they are not in a folder
     foreach ($this->folders['**[root]**'] as $p) {
         // Add all the placemark details
         $place = $folder->addChild('Placemark');
         $place->addAttribute('id', $p->getId());
         $place->addChild('name', $p->getName());
         $place->addChild('description', $p->getDesc());
         $place->addChild('styleUrl', $p->getStyle());
         // Add coordinates information
         $point = $place->addChild('Point');
         $point->addChild('coordinates', $p->getCoords());
     }
     // Put the xml into a string
     $kml = $sxe->asXML();
     // Kill $sxe to save memory
     $sxe = null;
     // Check that xml was returned
     if ($kml != false) {
         // Return the xml
         return $xml_head . $kml;
     }
 }
开发者ID:hamstar,项目名称:Create_KML,代码行数:66,代码来源:Create.php

示例6:

 $diameterIndex = $productDetail->setDiameterIndex($url);
 $diameterInfo = $productDetail->getDiameters($productHtml, $diameterIndex);
 $weightInfo = $productDetail->getWeight($productHtml);
 $colorInfo = $productDetail->getColor($productHtml);
 $description = $productDetail->getFeatures($productHtml);
 $diameter = $diameterInfo['diameter'];
 $diameterUnit = $diameterInfo['diameterUnit'];
 $weight = $weightInfo['weight'];
 $weightUnit = $weightInfo['weightUnit'];
 $packForm = $weightInfo['packForm'];
 $weightInKg = $weightInfo['weightInKg'];
 $colorNames = $colorInfo['colorNames'];
 $colorImgUrls = $colorInfo['colorImgUrls'];
 //没有颜色
 if (count($colorNames) == 0) {
     $productXml = $xml->addchild("product");
     $idXml = $productXml->addAttribute("id", $index);
     $materialTypeXml = $productXml->addchild("materialType", $materialType);
     $matherialSubTypeXml = $productXml->addchild("matherialSubType", "");
     $brandXml = $productXml->addchild("brand", "");
     $producerXml = $productXml->addchild("producer", $producer);
     $ingredientXml = $productXml->addchild("ingredient", "");
     $priceXml = $productXml->addchild("price", $price);
     $priceUnit = $productXml->addChild("priceUnit", $priceUnit);
     $diameterXml = $productXml->addchild("diameter", $diameter);
     $diameterUnit = $productXml->addchild("diameterUnit", $diameterUnit);
     $colorXml = $productXml->addchild("color", '');
     $colorImgUrlXml = $productXml->addchild("colorImgUrl", '');
     $weightXml = $productXml->addchild("weight", $weight);
     $weightUnit = $productXml->addchild("weightUnit", $weightUnit);
     $packFormXml = $productXml->addchild("packForm", $packForm);
开发者ID:OldMo,项目名称:3DPrintProject,代码行数:31,代码来源:FilamentPage.php

示例7: header

<?php

$srcxml = simplexml_load_string($HTTP_RAW_POST_DATA);
$card = $srcxml->QRY['CardCode'];
$xml = simplexml_load_file('in.xml');
$findcard = false;
$funcname = 'GetCardImageEx';
foreach ($xml->children() as $child) {
    if ($child->getName() == $funcname and $child["CardCode"] == (string) $card) {
        $imagesrc = 'images/' . $child["FileName"];
        $findcard = true;
        break;
    }
}
if ($findcard == true and file_exists($imagesrc)) {
    header('Content-Type: image/jpg');
    readfile($imagesrc);
    die;
} else {
    $findcard = false;
}
if ($findcard == false) {
    $newxml = new SimpleXMLElement('<?xml version="1.0" encoding="utf-8" ?><Root></Root>');
    $newxml->addchild($funcname);
    $newxml->{$funcname}->addattribute('ErrorText', 'Card or image not found');
    header('Content-Type: text/xml');
    echo $newxml->asXML();
}
开发者ID:rkeeper,项目名称:farcardsHTTP,代码行数:28,代码来源:getcardimageex.php

示例8: while

<?php

try {
    while (true) {
        sleep(10);
        $conn = new MongoClient();
        $db = $conn->selectDB('bilibili');
        $collection = new MongoCollection($db, 'videos');
        $cursor = $collection->find()->sort(array('aid' => -1))->limit(500);
        $arr = $cursor;
        $xml = new SimpleXMLElement('<?xml version="1.0" encoding="utf-8"?><document />');
        $xml->addchild("webSite", "v.dingxiaoyue.com");
        $xml->addchild("webMaster", "wsc449@qq.com");
        $xml->addchild("updatePeri", "60");
        foreach ($cursor as $doc) {
            $item = $xml->addchild("item");
            $item->addchild("op", "add");
            $item->addchild("title", $doc["title"]);
            $item->addchild("category", $doc["typename"]);
            $item->addchild("playLink", 'http://v.dingxiaoyue.com/view/' . $doc["aid"]);
            $item->addchild("imageLink", $doc["pic"]);
            $item->addchild("comment", addslashes($doc["description"]));
            $item->addchild("pubDate", $doc["created_at"]);
        }
        $xml->asXml("public/video.xml");
        $content = '<?xml version="1.0" encoding="UTF-8"?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1">';
        foreach ($arr as $doc) {
            $content .= "<url>\n";
            $content .= "<loc>" . 'http://v.dingxiaoyue.com/view/' . $doc["aid"] . "</loc>\n";
            $content .= "<video:video>";
            $content .= "<video:thumbnail_loc>" . $doc["pic"] . "</video:thumbnail_loc>\n";
开发者ID:wangshaochun,项目名称:bilibili-html5,代码行数:31,代码来源:videoXml.php

示例9: buildRateRequest

 /**
  *
  * This function set the xml to request rate
  * @param $productId
  * @param $checkinDate
  * @param $checkoutDate
  */
 function buildRateRequest($productId, $checkinDate, $checkoutDate)
 {
     $data = new SimpleXMLElement('<Data></Data>');
     $data->addChild("type", $this->productType);
     $data->addChild("method", "rates");
     $data->addChild("product_id", $productId);
     $data->addChild("checkin_date", $this->helper->setDateFormatToService($checkinDate));
     $data->addChild("checkout_date", $this->helper->setDateFormatToService($checkoutDate));
     //Set the currency id
     $currency = 0;
     if (isset($_SESSION["currentCurrency"]) && $_SESSION["currentCurrency"] != "") {
         $currency = $_SESSION["currentCurrency"];
     }
     $data->addchild("currency", $currency);
     return $data;
 }
开发者ID:jmangarret,项目名称:webtuagencia24,代码行数:23,代码来源:plan.php

示例10: external_comments_saveconf

function external_comments_saveconf()
{
    global $external_comments_conf;
    $configfile = GSDATAOTHERPATH . 'external_comments.xml';
    $xml_root = new SimpleXMLElement('<settings></settings>');
    $xml_root->addchild('provider', $external_comments_conf['provider']);
    $xml_root->addchild('developer', $external_comments_conf['developer']);
    $xml_root->addchild('shortname', $external_comments_conf['shortname']);
    if ($xml_root->asXML($configfile) === FALSE) {
        exit(i18n_r('external_comments/MSG_SAVEERROR') . ' ' . $configfile . ', ' . i18n_r('external_comments/MSG_CHECKPRIV'));
    }
}
开发者ID:RobAnt,项目名称:GetSimple-Plugins,代码行数:12,代码来源:external_comments.php

示例11: simplecache_saveconf

function simplecache_saveconf()
{
    global $simplecache_conf;
    $configfile = GSDATAOTHERPATH . 'simplecache.xml';
    $xml_root = new SimpleXMLElement('<simplecachesettings></simplecachesettings>');
    $xml_root->addchild('enabled', $simplecache_conf['enabled']);
    $xml_root->addchild('ttl', $simplecache_conf['ttl']);
    $nocache = $xml_root->addchild('nocache');
    foreach ($simplecache_conf['nocache'] as $slug) {
        $nocache->addchild('slug', $slug);
    }
    if ($xml_root->asXML($configfile) === FALSE) {
        exit('Unable to save ' . $configfile . ', check GetSimple privileges.');
    }
}
开发者ID:RobAnt,项目名称:GetSimple-Plugins,代码行数:15,代码来源:simplecache.php

示例12: simpletumblr_saveconf

function simpletumblr_saveconf()
{
    global $simpletumblr_conf;
    $configfile = GSDATAOTHERPATH . 'simpletumblr.xml';
    $xml_root = new SimpleXMLElement('<settings></settings>');
    $xml_root->addchild('name', $simpletumblr_conf['name']);
    $xml_root->addchild('count', $simpletumblr_conf['count']);
    $xml_root->addchild('imagesize', $simpletumblr_conf['imagesize']);
    $xml_root->addchild('type', $simpletumblr_conf['type']);
    if ($xml_root->asXML($configfile) === FALSE) {
        exit('Error saving ' . $configfile . ', check folder privlidges.');
    }
}
开发者ID:RobAnt,项目名称:GetSimple-Plugins,代码行数:13,代码来源:simpletumblr.php


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