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


PHP DOMDocument::createelement方法代码示例

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


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

示例1: exportAction

 public function exportAction()
 {
     $request = $this->getRequest();
     $minishop = $this->container->getParameter('minishop');
     $em = $this->getDoctrine()->getManager();
     $query = $em->getRepository("CoreProductBundle:Product")->findByCategoryQuery(null, false, true, false, false);
     if ($request->get('_locale')) {
         $query->setHint(\Gedmo\Translatable\TranslatableListener::HINT_TRANSLATABLE_LOCALE, $request->get('_locale'));
     }
     $medias = $em->getRepository("CoreProductBundle:ProductMedia")->getProductsMediasArray(null, array('image'), $request->get('_locale'));
     $videos = $em->getRepository("CoreProductBundle:ProductMedia")->getProductsMediasArray(null, array('video'), $request->get('_locale'));
     $stocks = $em->getRepository("CoreProductBundle:Stock")->getStocksArray(null, $request->get('_locale'));
     $prices = $em->getRepository("CoreProductBundle:Price")->getPricesArray();
     $categories = $em->getRepository("CoreProductBundle:ProductCategory")->getCategoriesArray(null, $request->get('_locale'));
     $attributes = $em->getRepository("CoreProductBundle:Attribute")->getGroupedAttributesByProducts(array(), array(), $request->get('_locale'));
     $options = $em->getRepository("CoreProductBundle:ProductOption")->getGroupedOptionsByProducts(array(), array(), $request->get('_locale'));
     $variations = $em->getRepository("CoreProductBundle:ProductVariation")->getGroupedVariationsByProducts(array(), $request->get('_locale'));
     $shippings = $em->getRepository("CoreShopBundle:Shipping")->getShippingQueryBuilder(null, true)->getQuery()->getResult();
     $googleProducts = $em->getRepository("CoreGoogleBundle:ProductCategory")->getGoogleCategoriesArray();
     $googleCategories = $em->getRepository("CoreGoogleBundle:CategoryCategory")->getGoogleCategoriesArray();
     $helper =& GoogleHelper::getCategories($request->get('_locale'));
     $pricegroup_id = $request->get('pricegroup');
     $priceGroup = null;
     if ($pricegroup_id !== null) {
         $priceGroup = $em->getRepository('CoreUserBundle:PriceGroup')->find($pricegroup_id);
     }
     $priceGroup = $priceGroup ? $priceGroup : $this->getPriceGroup();
     $currency_id = $request->get('currency');
     $currency = null;
     if ($currency_id !== null) {
         $currency = $em->getRepository('CorePriceBundle:Currency')->find($currency_id);
     }
     $currency = $currency ? $currency : $this->getCurrency();
     $pricetypes = $this->container->hasParameter('google.prices') ? $this->container->getParameter('google.prices') : array('normal');
     $delivery_id = $this->container->hasParameter('google.delivery_id') ? $this->container->getParameter('google.delivery_id') : array();
     $request = $this->getRequest();
     $document = new \DOMDocument('1.0', 'utf-8');
     $document->formatOutput = true;
     $rss = $document->appendChild($document->createElement('rss'));
     $rssversion = $document->createAttribute('version');
     $rssversion->value = "2.0";
     $rss->appendChild($rssversion);
     $rssns = $document->createAttribute('xmlns:g');
     $rssns->value = "http://base.google.com/ns/1.0";
     $rss->appendChild($rssns);
     $shop = $document->createelement('channel');
     $rss->appendChild($shop);
     $paths = array();
     //info
     $name = $document->createElement('title');
     $name->appendChild($document->createCDATASection($pname));
     $shop->appendChild($name);
     $url = $document->createElement('link');
     $routeParams = array();
     if ($request->get('_locale')) {
         $routeParams['_locale'] = $request->get('_locale');
     }
     $url->appendChild($document->createTextNode($this->generateUrl('category_homepage', $routeParams, true)));
     $shop->appendChild($url);
     $description = str_replace(array("\v", "", "\r", "\t"), ' ', strip_tags());
     // zrusenie niektorych whitespacesnakov za medzery
     $description = preg_replace('/\\s+/', ' ', $description);
     $description = str_replace(array(' ', '&'), array(" ", "&"), $description);
     $desc = $document->createElement('description');
     if (!empty($description)) {
         $desc->appendChild($document->createCDATASection($description));
     }
     $shop->appendChild($desc);
     //items
     foreach ($query->getResult() as $product) {
         $item = $document->createElement('item');
         $code = $document->createElement('g:id');
         $code->appendChild($document->createTextNode($product->getId()));
         $item->appendChild($code);
         $name = $document->createElement('title');
         $name->appendChild($document->createCDATASection($pname));
         $item->appendChild($name);
         $url = $document->createElement('link');
         $routeParams = array('slug' => $product->getSlug());
         if ($request->get('_locale')) {
             $routeParams['_locale'] = $request->get('_locale');
         }
         $url->appendChild($document->createTextNode($this->generateUrl('product_site', $routeParams, true)));
         $item->appendChild($url);
         $description = str_replace(array("\v", "", "\r", "\t"), ' ', strip_tags($product->getLongDescription() . " " . $product->getLongDescription()));
         // zrusenie niektorych whitespacesnakov za medzery
         $description = preg_replace('/\\s+/', ' ', $description);
         $description = str_replace(array(' ', '&'), array(" ", "&"), $description);
         $desc = $document->createElement('description');
         if (!empty($description)) {
             $desc->appendChild($document->createCDATASection($description));
         }
         $item->appendChild($desc);
         $code = $document->createElement('g:id');
         $code->appendChild($document->createTextNode($product->getId()));
         $item->appendChild($code);
         $status = $document->createElement('g:condition');
         $status->appendChild($document->createTextNode("new"));
         $item->appendChild($status);
         $cat = $document->createElement('g:google_product_category');
//.........这里部分代码省略.........
开发者ID:birko,项目名称:MiniShopGoogle,代码行数:101,代码来源:GoogleController.php

示例2: DOMDocument

<?php

$dom = new DOMDocument('1.0');
$books = $dom->appendchild($dom->CreateElement('books'));
$book = $books->appendchild($dom->CreateElement('book'));
$title = $book->appendchild($dom->createElement('title'));
$title->appendchild($dom->createTextNode('visual studio.net'));
$authar = $books->appendchild($dom->createelement('authar'));
$authar->appendchild($dom->createtextnode('.net'));
$dom->formatoutput = true;
$test1 = $dom->savexml();
$dom->save('exam6.xml');
开发者ID:chiragbutani,项目名称:PHP-Practice-Program,代码行数:12,代码来源:Pro6.php

示例3: foreach

                 $apr16_temp = $json->decode($apr16['server']);
                 if (isset($apr16_temp->result)) {
                     foreach ($apr16_temp->result as $resultval_apr) {
                         if (isset($resultval_apr->assoc)) {
                             $apr16_assoc_set = TRUE;
                             $assoc_val16 = $json->encode($resultval_apr->assoc);
                             $assoc_val16 = str_replace("{", "", $assoc_val16);
                             $assoc_val16 = str_replace("}", "", $assoc_val16);
                             $assoc_val16 = str_replace('"', "", $assoc_val16);
                             $temp_array16 = explode(",", $assoc_val16);
                             foreach ($temp_array16 as $skill_16) {
                                 $skill_16_temp = explode(":", $skill_16);
                                 $skill_16_el = $doc->createElement("skill");
                                 $skill_16_name_el = $doc->createElement("name");
                                 $skill_16_name_el->nodeValue = $skill_16_temp[0];
                                 $skill_16_model = $doc->createelement("model_name");
                                 $skill_16_model->nodeValue = "Imputed_Time";
                                 $skill_16_el->appendChild($skill_16_name_el);
                                 $skill_16_el->appendChild($skill_16_model);
                                 $tutor_msg_el->appendChild($skill_16_el);
                             }
                         }
                     }
                 }
             }
         }
     }
 }
 //April 16
 if (isset($server->result)) {
     //Create variable sat19_assoc_set and set it to FALSE
开发者ID:bvds,项目名称:andes,代码行数:31,代码来源:create-xml.php

示例4: header

 header('content-type:application/xml;charset=utf-8');
 header('cache-control:no-cache,must-revalidate');
 header('expires:fir,14 mar 1980 20:53:00 GMT');
 header('last-modified: ' . date('r'));
 header('pragma:no-cache');
 $dom = new DOMDocument('1.0');
 if (file_exists('guesebook.xml')) {
     $gb = simplexml_load_file('guesebook.xml');
     foreach ($gb->item as $item) {
         $gbit_arry[] = (int) $item->id;
     }
     $gbid = max($gbit_arry) + 1;
     $gb = dom_import_simplexml($gb);
     $gb = $dom->importnode($gb, true);
 } else {
     $gb = $dom->createelement('guestbook');
     $gbid = 1;
 }
 $gb = $dom->appendchild($gb);
 $item = $dom->createelement("item");
 //id
 $id = $dom->createelement('id');
 $text = $dom->createtextnode($gbid);
 $id->appendchild($text);
 $id = $item->appendchild($id);
 $user = $dom->createelement('user');
 $text = $dom->createtextnode(trim($_POST['user']));
 $user->appendchild($text);
 $user = $item->appendchild($user);
 $item = $gb->appendchild($item);
 echo $dom->saveXML();
开发者ID:shiyake,项目名称:PHP,代码行数:31,代码来源:guestbook.php


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