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


PHP domDocument::saveXML方法代码示例

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


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

示例1: generateDocument

 /**
  * @return string The WSDL document for this structure
  */
 public function generateDocument()
 {
     $this->addToDebug("Generating document");
     //add all definitions
     $definitions = $this->definitions;
     $definitions->setAttribute("xmlns", self::NS_WSDL);
     $definitions->setAttribute("xmlns:soap", self::NS_SOAP);
     $definitions->setAttribute("xmlns:SOAP-ENC", self::NS_ENC);
     $definitions->setAttribute("xmlns:wsdl", self::NS_WSDL);
     $definitions->setAttribute("xmlns:xsd", self::NS_XSD);
     $definitions->setAttribute("xmlns:apache", self::NS_APACHE);
     $definitions->setAttribute("xmlns:tns", $this->tns);
     $definitions->setAttribute("targetNamespace", $this->tns);
     //add all the services
     foreach ((array) $this->services as $serviceName => $service) {
         //add the portType
         $portType = $this->addPortType($serviceName);
         //add binding
         $binding = $this->addBinding($serviceName);
         //loop the operations
         foreach ((array) $service->methods as $operation) {
             $operationName = $operation->name;
             $operationTag = $this->addOperation($operationName, $serviceName);
             //input
             //only when to operation needs arguments
             $parameters = $operation->getParameters();
             if (count($parameters) > 0 || self::CREATE_EMPTY_INPUTS) {
                 $messageName = $operationName . "Request";
                 $input = $this->addElement("wsdl:input", $operationTag);
                 $input->setAttribute("message", "tns:" . $messageName);
                 $para = array();
                 foreach ((array) $parameters as $parameterName => $parameter) {
                     $para[$parameterName] = $parameter->type;
                 }
                 $this->addMessage($messageName, $para);
                 $this->addInput($this->bindingOperationTags[$serviceName][$operationName]);
             }
             //output
             //only when the operation returns something
             if (!$operation->return || trim($operation->return) == "") {
                 throw new WSDLException('No return type for ' . $operationName);
             }
             if (strtolower(trim($operation->return)) != 'void') {
                 $messageName = $operationName . "Response";
                 $output = $this->addElement("wsdl:output", $operationTag);
                 $output->setAttribute("message", "tns:" . $messageName);
                 $this->addOutput($this->bindingOperationTags[$serviceName][$operationName]);
                 $this->addMessage($messageName, array($operation->name . "Return" => $operation->return));
             }
         }
         // SH. now add the portType and binding
         $this->definitions->AppendChild($portType);
         $this->definitions->AppendChild($binding);
         //add the service
         $this->addService($serviceName);
     }
     return $this->doc->saveXML();
 }
开发者ID:medali1990,项目名称:medsite,代码行数:61,代码来源:WSDLStruct.class.php

示例2: calculate

 public function calculate()
 {
     $weight = $this->getTotalWeight() > 0 ? $this->getTotalWeight() : $this->avg_weight;
     $city = $this->getAddress('city') . ', ' . $this->getAddress('region');
     if ($city == '') {
         $services = 'Не задан город';
         return $services;
     }
     if (!extension_loaded('curl')) {
         $services = 'PHP extension CURL not loaded';
         return $services;
     }
     $dom = new domDocument("1.0", "utf-8");
     $root = $dom->createElement("request");
     $dom->appendChild($root);
     $child = $dom->createElement("function", "get_delivery_price");
     $root->appendChild($child);
     $child = $dom->createElement("api_id", $this->api_id);
     $root->appendChild($child);
     $child = $dom->createElement("from_city", $this->from_city_code_id);
     $root->appendChild($child);
     $child = $dom->createElement("to_city", $city);
     $root->appendChild($child);
     $child = $dom->createElement("pickup_place", 0);
     $root->appendChild($child);
     $child = $dom->createElement("weight", $weight);
     $root->appendChild($child);
     $child = $dom->createElement("order_price", $this->getTotalPrice());
     $root->appendChild($child);
     $child = $dom->createElement("num", $this->avg_num);
     $root->appendChild($child);
     $child = $dom->createElement("tarifs_type", 1);
     $root->appendChild($child);
     $child = $dom->createElement("price_options", 1);
     $root->appendChild($child);
     $child = $dom->createElement("delivery_partner", $this->partner);
     $root->appendChild($child);
     $res = $this->sendRequest($dom->saveXML());
     try {
         $xml = new SimpleXMLElement($res);
     } catch (Exception $e) {
         return 'Ошибка получения данных';
     }
     $price = (double) $xml->price;
     if ($xml->error_code > 0) {
         return "В заданный город доставка не осуществляется";
     }
     if ($xml->srok_dostavki != '') {
         $srok_dostavki = $xml->srok_dostavki . ' дн.';
     }
     $services['sl_courier'] = array('name' => 'до дверей', 'description' => '', 'id' => 'sl_courier', 'est_delivery' => $srok_dostavki, 'rate' => $price, 'currency' => 'RUB');
     return $services;
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:53,代码来源:shoplogisticscourierShipping.class.php

示例3: xmlSave

 function xmlSave($xmlfilename)
 {
     $dom = new domDocument();
     /*
         $complexe = $dom->appendChild(new DOMElement('complexe'));
         $reel = $complexe->appendChild(new DOMElement('reel'));
         $imag = $complexe->appendChild(new DOMElement('imag'));
         $reel->nodeValue=1;
         $imag->nodeValue=2;
     */
     $complexe = $dom->CreateElement('complexe');
     $dom->appendChild($complexe);
     $reel = $dom->CreateElement('reel', 1);
     $imag = $dom->CreateElement('imag', 2);
     $complexe->appendChild($reel);
     $complexe->appendChild($imag);
     // ToDo sérialisation XML
     print $dom->saveXML();
     $dom->save($xmlfilename);
 }
开发者ID:BackupTheBerlios,项目名称:openphysic-svn,代码行数:20,代码来源:index.php

示例4: frameResponse

 public function frameResponse(\FrameResponseObject $frameResponseObject)
 {
     $mplme = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $this->id);
     $frameResponseObject->setTitle("Mplme");
     if (isset($_REQUEST["xmlData"])) {
         $xmlDoc = \steam_factory::get_object_by_name($GLOBALS["STEAM"]->get_id(), $mplme->get_path() . "/data.xml");
         if ($xmlDoc === 0 || !$xmlDoc instanceof \steam_document) {
             $xml = simplexml_load_string("<datasets></datasets>");
             $xmlDoc = \steam_factory::create_document($GLOBALS["STEAM"]->get_id(), "data.xml", $xml->asXML(), "text/xml");
             $xmlDoc->move($mplme);
         } else {
             $xmlRaw = $xmlDoc->get_content();
             $xml = simplexml_load_string($xmlRaw);
         }
         $xmlRequest = simplexml_load_string($_REQUEST["xmlData"]);
         $xmlRequestDom = new \domDocument();
         $xmlRequestDom->loadXML($xmlRequest->asXML());
         $xmlDom = new \domDocument();
         $xmlDom->loadXML($xml->asXML());
         $xmlDom->documentElement->appendChild($xmlDom->importNode($xmlRequestDom->documentElement, true));
         if ($_FILES && is_array($_FILES)) {
             foreach ($_FILES as $file) {
                 $content = file_get_contents($file["tmp_name"]);
                 $doc = \steam_factory::create_document($GLOBALS["STEAM"]->get_id(), $file["name"], $content, $file["type"]);
                 $doc->move($mplme);
             }
         }
         $xmlDoc->set_content($xmlDom->saveXML());
         //echo "<pre>" . htmlentities($xmlDom->saveXML()) . "</pre>";
         echo "ok";
     } else {
         echo "nix";
     }
     die;
     //echo "done";
     //$frameResponseObject->addWidget(new \Widgets\Blank());
     //return $frameResponseObject;
 }
开发者ID:rolwi,项目名称:koala,代码行数:38,代码来源:Upload.class.php

示例5: getUnfilteredWebData

function getUnfilteredWebData($place_origin, $name_origin, $place_destination, $type_destination)
{
    global $config_url_efa;
    $curl_conenction = prepare_curl_connection($config_url_efa);
    $post_data = build_post_array($place_origin, $name_origin, $place_destination, $type_destination);
    $result = execute_curl_connection($curl_conenction, $post_data);
    /*** a new dom object ***/
    $dom = new domDocument();
    @$dom->loadHTML($result);
    $dom->preserveWhiteSpace = false;
    $table_list = $dom->getElementsByTagName('table');
    foreach ($table_list as $table) {
        if ($table->hasAttributes()) {
            foreach ($table->attributes as $attribute) {
                if ($attribute->value == "100%") {
                    $dom_ele_timetable = $table;
                    break;
                }
            }
        }
    }
    $xml_string = str_replace("&#13;", "", $dom->saveXML($dom_ele_timetable));
    return $xml_string;
}
开发者ID:ItsLines,项目名称:ThePreviouslyDesigned,代码行数:24,代码来源:efa_lib.php

示例6: while

            case $key == 'objectives':
                $newnode = $doc->createElement($key, $val2);
                $doc->appendChild($newnode);
                $add = $doc->getElementsByTagName('SET_OF_SOLUTIONS')->item(0);
                $add->appendChild($newnode);
                break;
                //********************************************************************************
            //********************************************************************************
            case $key == 'relatedPatterns':
                while (list($key2, $val2) = each($newval)) {
                    $newnode = $doc->createElement($key, $val2);
                    $doc->appendChild($newnode);
                    $add = $doc->getElementsByTagName('SET_OF_RELATED_PATTERNS')->item(0);
                    $add->appendChild($newnode);
                }
                break;
                //**********************patern Identification******************
            //**********************patern Identification******************
            case $key == 'autors':
                $newnode = $doc->createElement($key, $val2);
                $doc->appendChild($newnode);
                $add = $doc->getElementsByTagName('PATTERN_IDENTIFICATION')->item(0);
                $add->appendChild($newnode);
                break;
        }
    }
}
$doc->save(XML_PATH . 'myxml.xml');
$res = $doc->saveXML();
print $res;
echo "file created";
开发者ID:laiello,项目名称:dp-navigator,代码行数:31,代码来源:createXml7.php

示例7: htmlspecialchars

		<!ENTITY bmw "BMW">
		<!ENTITY patron "<patrons>Petrov V.</patrons>">
	]>
	<gar:garages xmlns:gar = "http://mysite.ru" xmlns:carpark = "http://mysite.ru/auto">
		<gar:garage gar:number="1">
			Garage #1:
			<![CDATA[
			<?xml version="1.0"?>
			]]>
			<carpark:auto>
				<mark>&bmw;</mark>
				<owner>Ivaniv I. (&lt; &gt; &apos; &amp; &quot; &#400; &#120; &#380;)</owner>
			</carpark:auto>
			<auto xmlns = "http://mysite.ru/BMW">
				<mark>Toyota</mark>
				<owner>&patron;</owner>
			</auto>
		</gar:garage> 
		<date/>
	</gar:garages>';
	
	//$document->loadXML($xmldocument);
	$document->load("test.xml");
	//$document->save("test.xml");
	echo htmlspecialchars($document->saveXML());
	
	
	
	
	
?>
开发者ID:echmaster,项目名称:data,代码行数:31,代码来源:7+Класс+DOMDocument.php

示例8: nl2br

<?php

$dom = new domDocument('1.0');
$dom->formatOutput = true;
// make output be nicely formatted
$root = $dom->createElement('root');
// create new element
foreach (array('foo', 'bar', 'baz') as $v) {
    $node = $dom->createElement($v);
    // create new sub-element
    $node->appendChild($dom->createTextNode($v));
    // add value to element
    $root->appendChild($node);
    // append sub-element to root element
}
$dom->appendChild($root);
// add root node to document
$xml = $dom->saveXML();
// output XML
echo nl2br(htmlspecialchars($xml));
开发者ID:SandyS1,项目名称:presentations,代码行数:20,代码来源:obj_dom.php

示例9: array

    $x = $ps->item($i);
    // delete links, sups and spans
    $delist = array();
    $links = $x->getElementsByTagName('a');
    foreach ($links as $link) {
        $txt = new domText($link->nodeValue);
        $link->parentNode->insertBefore($txt, $link);
        $delist[] = $link;
    }
    $links = $x->getElementsByTagName('sup');
    foreach ($links as $link) {
        $delist[] = $link;
    }
    $links = $x->getElementsByTagName('span');
    foreach ($links as $link) {
        $delist[] = $link;
    }
    foreach ($delist as $del) {
        $del->parentNode->removeChild($del);
    }
    if (strlen($x->nodeValue)) {
        $wiki[] = $x;
        $strlen += strlen($x->nodeValue);
    }
    $i++;
} while ($strlen < 700);
foreach ($wiki as $w) {
    echo $dom->saveXML($w) . "\n";
}
echo $i . "\n";
//file_put_contents('/Users/roberto/Desktop/humanp.txt',$ps->item(1)->nodeValue);
开发者ID:katjaq,项目名称:braincatalogue,代码行数:31,代码来源:wiki.php

示例10: htmlspecialchars

<?php

/*КЛАСС DOMElement урок 10*/
//Объект данного класса представляет собой элемент XML-документа
//Метод getElementsByTagName() объекта класса domDocument - возвращает объект класса NodeList (похож на объект класса NamedNodMap), этот объект хранит дочерние узлы, для него первостепенное это порядок.
//Свойство length объекта класса NodeList - возвращает длину массива элементов
//Метод item() объекта класса NodeList - возвращает объект класса Node
//Свойство nodeName объекта класса Node - возвращает имя сущности ($node->nodeName)
//Метод getAttribute("number") объекта класса Node - возвращает значение указанного атрибута(1-указываем атрибут)
//Метод getAttributeNS("http://mysite.ru","number") объекта класса Node - возвращает значение указанного атрибута, используется тогда когда применяется namespace (1- указываем namespace ,2-указываем атрибут)
//Метод setAttribute("number", 20) объекта класса Node - изменяет значение указанного атрибута(1-указываем атрибут, 2- значение атрибута)
//Метод setAttributeNS("http://mysite.ru","number", 20) объекта класса Node - изменяет значение указанного атрибута, используется тогда когда применяется namespace (1- указываем namespace ,2-указываем атрибут, 3-значение атрибута)
$document = new domDocument("1.0", "utf-8");
$document->load("test.xml");
echo htmlspecialchars($document->saveXML()) . "<br/>";
echo "<br/>------------------------------<br/>";
$nodelist = $document->getElementsByTagName("garage");
for ($i = 0; $i < $nodelist->length; $i++) {
    $node = $nodelist->item($i);
    echo $node->nodeName . "<br/>";
    echo $node->getAttributeNS("http://mysite.ru", "number") . "<br/>";
    echo $node->setAttributeNS("http://mysite.ru", "number", 20);
    echo $node->getAttributeNS("http://mysite.ru", "number") . "<br/>";
}
echo "<br/>------------------------------<br/>";
echo htmlspecialchars($document->saveXML()) . "<br/>";
开发者ID:echmaster,项目名称:data,代码行数:26,代码来源:10+Класс+DOMElement.php

示例11: readability_object

 /**
  * Runs a URL through Readability and hands back the stripped content
  *
  * @since 1.7
  * @see http://www.keyvan.net/2010/08/php-readability/
  * @param $url
  */
 public static function readability_object($url)
 {
     set_time_limit(0);
     $url = pf_de_https($url);
     $url = str_replace('&amp;', '&', $url);
     //print_r($url); print_r(' - Readability<br />');
     // change from Boone - use wp_remote_get() instead of file_get_contents()
     $request = wp_remote_get($url, array('timeout' => '30'));
     if (is_wp_error($request)) {
         $content = 'error-secured';
         //print_r($request); die();
         return $content;
     }
     if (!empty($request['body'])) {
         $html = $request['body'];
     } else {
         $content = false;
         return $content;
     }
     //check if tidy exists to clean up the input.
     if (function_exists('tidy_parse_string')) {
         $tidy = tidy_parse_string($html, array(), 'UTF8');
         $tidy->cleanRepair();
         $html = $tidy->value;
     }
     // give it to Readability
     $readability = new Readability($html, $url);
     // print debug output?
     // useful to compare against Arc90's original JS version -
     // simply click the bookmarklet with FireBug's
     // console window open
     $readability->debug = false;
     // convert links to footnotes?
     $readability->convertLinksToFootnotes = false;
     // process it
     $result = $readability->init();
     if ($result) {
         $content = $readability->getContent()->innerHTML;
         //$content = $contentOut->innerHTML;
         //if we've got tidy, let's use it.
         if (function_exists('tidy_parse_string')) {
             $tidy = tidy_parse_string($content, array('indent' => true, 'show-body-only' => true), 'UTF8');
             $tidy->cleanRepair();
             $content = $tidy->value;
         }
         $content = balanceTags($content, true);
         $content = ent2ncr($content);
         $content = convert_chars($content);
         $domRotated = 0;
         $dom = new domDocument('1.0', 'utf-8');
         $dom->preserveWhiteSpace = true;
         $dom->substituteEntities = true;
         $dom->resolveExternals = true;
         $dom->loadXML('<fullContent>' . $content . '</fullContent>');
         $images = $dom->getElementsByTagName('img');
         foreach ($images as $image) {
             $img = $image->getAttribute('src');
             if (strpos($img, '/') === 0 || strpos($img, 'http') != 0) {
                 $urlArray = parse_url($url);
                 if (strpos($img, 'http') != 0) {
                     $urlBase = 'http://' . $urlArray['host'] . '/';
                 } else {
                     $urlBase = 'http://' . $urlArray['host'];
                 }
                 if (!is_wp_error(wp_remote_head($urlBase . $img))) {
                     $image->setAttribute('src', $urlBase . $img);
                     $domRotated++;
                 } elseif (!is_wp_error(wp_remote_head($url . $img))) {
                     $image->setAttribute('src', $url . $img);
                     $domRotated++;
                 } else {
                     $image->parentNode->removeChild($image);
                     $domRotated++;
                 }
             }
         }
         if ($domRotated > 0) {
             $content = $dom->saveXML();
             $rel = '(<\\?xml version="1\\.0" encoding="utf-8"\\?>)';
             $content = preg_replace("/" . $rel . "/is", ' ', $content);
             $rel = '(<\\?xml version="1\\.0"\\?>)';
             $content = preg_replace("/" . $rel . "/is", ' ', $content);
         }
         if (120 > strlen($content)) {
             $content = false;
         }
         #			$content = stripslashes($content);
         # print_r($content);
         #				var_dump($content); die();
         // this will also output doctype and comments at top level
         #			$content = "";
         #			foreach($dom->childNodes as $node){
         #				$content .= $dom->saveXML($node)."\n";
//.........这里部分代码省略.........
开发者ID:dangeles,项目名称:Phinch,代码行数:101,代码来源:readable.php

示例12: request

 public function request($arg)
 {
     $site = litepublisher::$site;
     $s = '<?php turlmap::sendxml(); ?>';
     switch ($arg) {
         case 'manifest':
             $s .= '<manifest xmlns="http://schemas.microsoft.com/wlw/manifest/weblog">' . '<options>' . '<clientType>WordPress</clientType>' . '<supportsKeywords>Yes</supportsKeywords>' . '<supportsGetTags>Yes</supportsGetTags>' . '<supportsNewCategories>Yes</supportsNewCategories>' . '</options>' . '<weblog>' . '<serviceName>Lite Publisher</serviceName>' . "<homepageLinkText>{$site->name}</homepageLinkText>" . "<adminLinkText>{$site->name}</adminLinkText>" . "<adminUrl>{$site->url}/admin/</adminUrl>" . '<postEditingUrl>' . "<![CDATA[{$site->url}/admin/posts/editor/{$site->q}id={post-id}]]>" . '</postEditingUrl>' . '</weblog>' . '<buttons>' . '<button>' . '<id>0</id>' . '<text>Manage Comments</text>' . '<imageUrl>/favicon.ico</imageUrl>' . '<clickUrl>' . "<![CDATA[{$site->url}/admin/comments/]]>" . '</clickUrl>' . '</button>' . '</buttons>' . '</manifest>';
             break;
         case 'rsd':
             /*
             $s .= '<rsd version="1.0" xmlns="http://archipelago.phrasewise.com/rsd">' .
             '<service>' .
             '<engineName>Lite Publisher</engineName>' .
             '<engineLink>http://litepublisher.com/</engineLink>' .
             "<homePageLink>$site->url/</homePageLink>" .
             '<apis>' .
             '<api name="WordPress" blogID="1" preferred="true" apiLink="' . $site->url . '/rpc.xml" />' .
             '<api name="Movable Type" blogID="1" preferred="false" apiLink="' . $site->url . '/rpc.xml" />' .
             '<api name="MetaWeblog" blogID="1" preferred="false" apiLink="' . $site->url . '/rpc.xml" />' .
             '<api name="Blogger" blogID="1" preferred="false" apiLink="' . $site->url . '/rpc.xml" />' .
             '</apis>' .
             '</service>' .
             '</rsd>';
             */
             $dom = new domDocument();
             $dom->encoding = 'utf-8';
             $rsd = $dom->createElement('rsd');
             $dom->appendChild($rsd);
             tnode::attr($rsd, 'version', '1.0');
             tnode::attr($rsd, 'xmlns', 'http://archipelago.phrasewise.com/rsd');
             $service = tnode::add($rsd, 'service');
             tnode::addvalue($service, 'engineName', 'LitePublisher');
             tnode::addvalue($service, 'engineLink', 'http://litepublisher.com/');
             tnode::addvalue($service, 'homePageLink', litepublisher::$site->url . '/');
             $apis = tnode::add($service, 'apis');
             $api = tnode::add($apis, 'api');
             tnode::attr($api, 'name', 'WordPress');
             tnode::attr($api, 'blogID', '1');
             tnode::attr($api, 'preferred', 'true');
             tnode::attr($api, 'apiLink', litepublisher::$site->url . '/rpc.xml');
             $api = tnode::add($apis, 'api');
             tnode::attr($api, 'name', 'Movable Type');
             tnode::attr($api, 'blogID', '1');
             tnode::attr($api, 'preferred', 'false');
             tnode::attr($api, 'apiLink', litepublisher::$site->url . '/rpc.xml');
             $api = tnode::add($apis, 'api');
             tnode::attr($api, 'name', 'MetaWeblog');
             tnode::attr($api, 'blogID', '1');
             tnode::attr($api, 'preferred', 'false');
             tnode::attr($api, 'apiLink', litepublisher::$site->url . '/rpc.xml');
             $api = tnode::add($apis, 'api');
             tnode::attr($api, 'name', 'Blogger');
             tnode::attr($api, 'blogID', '1');
             tnode::attr($api, 'preferred', 'false');
             tnode::attr($api, 'apiLink', litepublisher::$site->url . '/rpc.xml');
             $xml = $dom->saveXML();
             $s .= substr($xml, strpos($xml, '?>') + 2);
             break;
     }
     return $s;
 }
开发者ID:laiello,项目名称:litepublisher,代码行数:61,代码来源:manifest.class.php

示例13: generateRss

 public function generateRss()
 {
     $xml_par = $this->getXml();
     $xml_version = $xml_par['version'];
     $xml_charset = $xml_par['charset'];
     $xml = new domDocument($xml_version, $xml_charset);
     $rss = $xml->createElement('rss');
     //rss
     foreach ($this->getRss() as $key => $value) {
         $rss->setAttribute($key, $value);
     }
     $xml->appendChild($rss);
     //channel
     $channel = $xml->createElement('channel');
     foreach ($this->channel as $key => $value) {
         $row = $xml->createElement($key, $value['val']);
         if (!empty($value['attr'])) {
             foreach ($value['attr'] as $attr_key => $attr_val) {
                 $row->setAttribute($attr_key, $attr_val);
             }
         }
         $channel->appendChild($row);
     }
     $rss->appendChild($channel);
     foreach ($this->items as $item_key => $item) {
         $item_element = $xml->createElement('item');
         foreach ($item as $key => $value) {
             $row = $xml->createElement($key, $value['val']);
             if (!empty($value['attr'])) {
                 foreach ($value['attr'] as $attr_key => $attr_val) {
                     $row->setAttribute($attr_key, $attr_val);
                 }
             }
             $item_element->appendChild($row);
         }
         $channel->appendChild($item_element);
     }
     return $xml->saveXML();
 }
开发者ID:DaaGER,项目名称:php-rss-creator,代码行数:39,代码来源:RssCreator.php

示例14: str_replace

************************************************************************************************************************************/
/**
* Usage example: find synonym for a word
*/
define("BASE_URL", "http://encarta.msn.com/encnet/features/dictionary/DictionaryResults.aspx");
echo $_REQUEST["key_word"];
$request_url = BASE_URL . "?lextype=2&search=" . $_REQUEST["key_word"];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $request_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$output = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
$output = str_replace("class=\"ResultBody\"", "id=\"ResultBody\"", $output);
/*** a new dom object ***/
$dom = new domDocument();
/*** load the output html into the object ***/
$dom->loadHTML($output);
/*** discard white space ***/
$dom->preserveWhiteSpace = false;
$html = $dom->saveXML($dom->getElementById("ResultBody"));
$xml = simplexml_load_string($html);
//print_r($html);
$synonyms = str_replace(":", "", simplexml_import_dom($xml));
$result = $xml->xpath('/span/a/b');
$synonyms .= ", ";
while (list(, $node) = each($result)) {
    $synonyms .= $node->asXML() . ", ";
}
echo str_replace("</b>", "", str_replace("<b>", "", $synonyms));
开发者ID:henryjiang,项目名称:SF311-Facebook,代码行数:31,代码来源:synonym.php

示例15: xml

 protected function xml($datafeed, $filename, $user_id = '')
 {
     $temp_file = base_dir() . 'buyers_files' . DIRECTORY_SEPARATOR . $user_id . $filename;
     if (!file_exists($temp_file)) {
         $this->load->helper('download');
         $dom = new domDocument("1.0", "utf-8");
         $root = $dom->createElement("items");
         $dom->appendChild($root);
         foreach ($datafeed as $feed) {
             if ($feed->ic_id == "") {
                 continue;
             }
             $feed->ic_retail_price = trim($feed->ic_retail_price) == '' || $feed->ic_retail_price == 0 ? $feed->ic_price * 3 : $feed->ic_retail_price;
             $item = $dom->createElement("item");
             $item->setAttribute("id", $feed->ic_id);
             $params = array();
             $params['SKU'] = $dom->createElement("SKU", $feed->SKU);
             $params['Barcode'] = $dom->createElement("Barcode", $feed->upc_ean);
             $params['Manufacturer_Part_Number'] = $dom->createElement("Manufacturer_Part_Number", $feed->manuf_num);
             $params['Manufacturer_Name'] = $dom->createElement("Manufacturer_Name", $feed->m_name);
             $params['Brand_Name'] = $dom->createElement("Brand_Name", $feed->b_name);
             $params['Title'] = $dom->createElement("Title", $feed->tr_title);
             $params['Description'] = $dom->createElement("Description", htmlspecialchars(strip_tags($feed->tr_desc)));
             $params['Category_ID'] = $dom->createElement("Category_ID", $feed->c_id);
             $params['Category_Name'] = $dom->createElement("Category_Name", htmlspecialchars($this->getFullCategoryName($feed->c_id)));
             $params['Weight'] = $dom->createElement("Weight", $feed->weight + " " + $feed->weightScale);
             $params['Ship_Alone'] = $dom->createElement("Ship_Alone", $feed->ship_alone);
             $params['Height'] = $dom->createElement("Height", $feed->d_height + " " + $feed->d_scale);
             $params['Width'] = $dom->createElement("Width", $feed->d_width + " " + $feed->d_scale);
             $params['Depth'] = $dom->createElement("Depth", $feed->d_dept + " " + $feed->d_scale);
             $params['LeadTime'] = $dom->createElement("LeadTime", $feed->ic_leadtime);
             $params['Quantity_In_Stock'] = $dom->createElement("Quantity_In_Stock", $feed->ic_quan);
             $params['Selling_Price'] = $dom->createElement("Selling_Price", $feed->ic_price);
             $params['MSRP'] = $dom->createElement("MSRP", $feed->ic_retail_price);
             $params['Promo_Text'] = $dom->createElement("Promo_Text", $feed->ic_prom_text);
             $params['MAP'] = $dom->createElement("MAP", $feed->ic_map);
             $params['Shipping_Cost'] = $dom->createElement("Shipping_Cost", $feed->ic_ship_cost);
             $params['Min_Order'] = $dom->createElement("Min_Order", $feed->ic_min_order);
             $params['Case_Pack'] = $dom->createElement("Case_Pack", $feed->ic_case_pack);
             $this->load->model('inventories');
             $image_list = $this->inventories->list_image($feed->i_id);
             $images = $dom->createElement("images");
             foreach ($image_list as $image) {
                 $pic_name = $dom->createElement("image", base_url() . $image->ii_link);
                 $images->appendChild($pic_name);
             }
             foreach ($params as $param) {
                 $item->appendChild($param);
             }
             $item->appendChild($images);
             $root->appendChild($item);
         }
         force_download($filename, $dom->saveXML());
     } else {
         set_time_limit(0);
         ini_set('memory_limit', '512M');
         my_force_download($temp_file);
     }
 }
开发者ID:rnlduadia,项目名称:LAMP-eCommerce-CodeIgniter,代码行数:59,代码来源:datafeed.php


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