/**
  * @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();
 }
 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;
 }
 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);
 }
Beispiel #4
0
 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;
 }
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;
}
Beispiel #6
0
            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";
		<!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());
	
	
	
	
	
?>
Beispiel #8
0
<?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));
Beispiel #9
0
    $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);
<?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/>";
Beispiel #11
0
 /**
  * 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";
         #			}
     } else {
         # If Readability can't get the content, send back a FALSE to loop with.
         $content = false;
         # and let's throw up an error via AJAX as well, so we know what's going on.
         //print_r($url . ' fails Readability.<br />');
     }
     if ($content != false) {
         $contentObj = new pf_htmlchecker($content);
         $content = $contentObj->closetags($content);
     }
     return $content;
 }
 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;
 }
Beispiel #13
0
 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();
 }
Beispiel #14
0
************************************************************************************************************************************/
/**
* 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));
 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);
     }
 }
Beispiel #16
0
        $expected = $dom->createElement("ThisExpected", $pdo['expected']);
        $product->appendChild($article);
        $product->appendChild($quantity);
        $product->appendChild($price);
        $product->appendChild($expected);
        $products->appendChild($product);
    }
    $order->appendChild($number);
    $order->appendChild($wh);
    $order->appendChild($pt);
    $order->appendChild($clientID);
    $order->appendChild($clientName);
    $order->appendChild($clientCompany);
    $order->appendChild($email);
    $order->appendChild($phone);
    $order->appendChild($comment);
    $order->appendChild($products);
    $root->appendChild($order);
}
/*for ($i = 0; $i < count($logins); $i++) {
    $id = $i + 1; // id-пользователя
    $user = $dom->createElement("user"); // Создаём узел "user"
    $user->setAttribute("id", $id); // Устанавливаем атрибут "id" у узла "user"
    $login = $dom->createElement("login", $logins[$i]); // Создаём узел "login" с текстом внутри
    $password = $dom->createElement("password", $passwords[$i]); // Создаём узел "password" с текстом внутри
    $user->appendChild($login); // Добавляем в узел "user" узел "login"
    $user->appendChild($password);// Добавляем в узел "user" узел "password"
    $root->appendChild($user); // Добавляем в корневой узел "users" узел "user"
}*/
echo $dom->saveXML();
// Сохраняем полученный XML-документ в файл
Beispiel #17
0
$attr = $rootnode->getAttributeNode("src");
print_node($attr);
echo "--------- Remove Attribute Node\n";
$attr = $rootnode->removeAttribute("src");
print "Removed " . $attr . " attributes.\n";
echo "--------- attributes of rootnode\n";
$attrs = $rootnode->attributes;
print_node_list($attrs);
echo "--------- children of an attribute\n";
$children = $attrs->item(0)->childNodes;
print_node_list($children);
echo "--------- Add child to root\n";
$myelement = new domElement("Silly", "Symphony");
$newchild = $rootnode->appendChild($myelement);
print_node($newchild);
print $dom->saveXML();
print "\n";
echo "--------- Find element by tagname\n";
echo "    Using dom\n";
$children = $dom->getElementsByTagname("Silly");
print_node_list($children);
echo "    Using elem\n";
$children = $rootnode->getElementsByTagName("Silly");
print_node_list($children);
echo "--------- Unlink Node\n";
print_node($children->item(0));
$rootnode->removeChild($children->item(0));
print_node_list($rootnode->childNodes);
print $dom->savexml();
echo "--------- Find element by id\n";
print "Not implemented\n";
Beispiel #18
0
function tagwrap($html, $width = 75, $break = "nr")
{
    $html = '<div>' . $html . '</div>';
    //using dom object
    $dom = new domDocument();
    //load the html into the object
    $dom->loadXML($html);
    // preserve white space
    $dom->preserveWhiteSpace = true;
    //getting all tags
    $content = $dom->getElementsByTagname("*");
    $html = "";
    foreach ($content as $item) {
        //wrapping contents of tags, function described above is used,
        //but you can use your own function or simple wordwrap() php function
        $item->nodeValue = mb_wordwrap($item->nodeValue, $width, $break);
        $html .= $dom->saveXML($item);
    }
    //return the results
    return $html;
    //html_entity_decode($html);
}