コード例 #1
0
ファイル: XmlWriter.php プロジェクト: Masterfion/plugin-sonos
 /**
  * Convert the internal dom instance to a string.
  *
  * @param boolean $format Whether to pretty format the string or not
  *
  * @return string
  */
 public function toString($format = null)
 {
     if ($format) {
         $this->dom->formatOutput = true;
     }
     return $this->dom->saveXML();
 }
コード例 #2
0
ファイル: HTMLDoc.php プロジェクト: ringmaster/microsite2
 /**
  * Return the HTML represented by the DOM
  * @return string The requested HTML
  */
 public function get()
 {
     $body_content = $this->query('//body/*');
     $output = '';
     foreach ($body_content as $node) {
         $output .= $this->dom->saveXML($node->node);
     }
     return $output;
 }
コード例 #3
0
ファイル: Xml.php プロジェクト: leedavis81/drest-common
 /**
  * @see Drest\Writer\Writer::write()
  */
 public function write(ResultSet $data)
 {
     $this->xml = new \DomDocument('1.0', 'UTF-8');
     $this->xml->formatOutput = true;
     $dataArray = $data->toArray();
     if (key($dataArray) === 0) {
         // If there is no key, we need to use a default
         $this->xml->appendChild($this->convertArrayToXml('result', $dataArray));
     } else {
         $this->xml->appendChild($this->convertArrayToXml(key($dataArray), $dataArray[key($dataArray)]));
     }
     $this->data = $this->xml->saveXML();
 }
コード例 #4
0
ファイル: client.php プロジェクト: Acedrin/PGROU
function format($xml)
{
    $dom = new DomDocument();
    $dom->loadXML($xml);
    $dom->formatOutput = true;
    return $dom->saveXML();
}
コード例 #5
0
 public function showAction()
 {
     set_time_limit(600);
     // 10 min
     //		ini_set('output_buffering', '4096');
     $nodeid = $this->getRequest()->getParam('id', -1);
     $this->_zip = new Uman_ZipStream("pack_{$nodeid}.pkg");
     $xml = new DomDocument('1.0', 'utf-8');
     $root = $xml->appendChild(new DOMElement('package'));
     $content = $xml->createElement('content');
     $content = $root->appendChild($content);
     $this->addLevel($this->_db->fetchAll($this->_rootsql, $nodeid), $content, $this->getRequest()->getParam('contentinc', false));
     $packid = $this->_db->nextSequenceId('GEN_UID');
     $this->addInfo($nodeid, $root, $packid);
     $this->addTypes($root);
     $this->_zip->add_file('info.xml', $xml->saveXML());
     $this->_zip->finish();
     $AdminDbModel = new Admin_Model_Admin();
     $AdminDbModel->exportPackage($nodeid, $packid);
     /*		header("Content-type: application/x-zip");
     		header("Content-Disposition: attachment; filename=test.zip");
     				
     		$zip = new ZipArchive();
     		if ($zip->open('php://output', ZIPARCHIVE::CREATE)!==TRUE) { // Пока не работает запись в поток
         	echo "cannot open \n";
         	exit;
     		}
     		$zip->addFromString('test.txt', '11111111111');
     		$zip->close();	
     */
     exit;
 }
コード例 #6
0
ファイル: PiratizeAbstract.php プロジェクト: DiegoPino/mik
 /**
  * General manipulate wrapper method.
  *
  * @param string $input An XML snippet to be manipulated. We are only interested
  *    in <abstract> snippets.
  *
  * @return string
  *     Manipulated string
  */
 public function manipulate($input)
 {
     $dom = new \DomDocument();
     $dom->loadxml($input, LIBXML_NSCLEAN);
     $abstracts = $dom->getElementsByTagName('abstract');
     if ($abstracts->length == 1) {
         $abstract = $abstracts->item(0);
         // Use Guzzle to hit the API.
         $client = new Client();
         try {
             $original_text = urlencode($abstract->nodeValue);
             $query = "?text={$original_text}&format=json";
             $response = $client->get($this->arrpiUrl . $query);
             // If there is a Guzzle error, log it and return the original snippet.
         } catch (Exception $e) {
             $this->log->addWarning("PiratizeAbstract", array('HTTP request error' => $e->getMessage()));
             return $input;
         }
         $body = $response->getBody();
         $translation = json_decode($body, true);
         $abstract->nodeValue = urldecode($translation['translation']['pirate']);
         // Log any instances where the translation differs from the original text.
         if (urldecode($original_text) != $abstract->nodeValue) {
             $this->log->addInfo("PiratizeAbstract", array('Record key' => $this->record_key, 'Source abstract text' => urldecode($original_text), 'Piratized abstract text' => $abstract->nodeValue));
         }
         // We're done, so return the modified snippet.
         return $dom->saveXML($dom->documentElement);
     } else {
         return $input;
     }
 }
コード例 #7
0
 /**
  * return the document as string.
  *
  * @access public
  * @return string
  */
 public function __toString()
 {
     $this->document->formatOutput = true;
     $this->document->preserveWhitespace = false;
     $title = $this->document->createElement('title', $this->getFullTitle());
     $this->head->appendChild($title);
     if (!empty($this->favicon)) {
         $favicon = $this->document->createElement('link');
         $favicon->setAttribute('rel', 'shortcut icon');
         $favicon->setAttribute('href', $this->favicon);
         $this->head->appendChild($favicon);
         $favicon = $this->document->createElement('link');
         $favicon->setAttribute('rel', 'icon');
         $favicon->setAttribute('href', $this->favicon);
         $this->head->appendChild($favicon);
     }
     if (!empty($this->keywords)) {
         $keywords = $this->document->createElement('meta');
         $keywords->setAttribute('name', 'keywords');
         $keywords->setAttribute('content', $this->keywords);
         $this->head->appendChild($keywords);
     }
     $html = $this->document->getElementsByTagName('html')->item(0);
     $html->appendChild($this->head);
     $html->appendChild($this->body);
     return $this->document->saveXML();
 }
コード例 #8
0
ファイル: calendar.php プロジェクト: kwonyoungjae/MoneyBook
function makeXml($dbObject)
{
    header("Content-Type: application/xml");
    $doc = new DomDocument('1.0', 'UTF-8');
    $uid = $doc->createElement('uid');
    for ($i = 0; $i < $dbObject->rowCount(); $i++) {
        $result = $dbObject->fetch();
        if ($i === 0) {
            $id = $doc->createAttribute('id');
            $id->value = $result['usernum'];
            $uid->appendChild($id);
            $doc->appendChild($uid);
        }
        $prefix = array($result['num'], $result['in_out'], $result['type'], $result['amount'], $result['time'], $result['detail']);
        list($tnum, $inout, $type, $amount, $time, $detail) = $prefix;
        $trade_num = $doc->createElement('tnum');
        $tr_att = $doc->createAttribute('nu');
        $tr_att->value = $tnum;
        $trade_num->appendChild($tr_att);
        $trade_num->appendChild($doc->createElement('inout', $inout));
        $trade_num->appendChild($doc->createElement('type', $type));
        $trade_num->appendChild($doc->createElement('amount', $amount));
        $trade_num->appendChild($doc->createElement('time', $time));
        $trade_num->appendChild($doc->createElement('detail', $detail));
        $uid->appendChild($trade_num);
    }
    $xml = $doc->saveXML();
    print $xml;
}
コード例 #9
0
function do_refresh_task($task_id_)
{
    $task = Abstract_Task::load($task_id_);
    if (!is_object($task)) {
        Logger::error('main', '(ajax/installable_applications) Task ' . $task_id_ . ' not found');
        header('Content-Type: text/xml; charset=utf-8');
        $dom = new DomDocument('1.0', 'utf-8');
        $node = $dom->createElement('usage');
        $node->setAttribute('status', 'task not found');
        $dom->appendChild($node);
        die($dom->saveXML());
    }
    $task->refresh();
    if (!$task->succeed()) {
        header('Content-Type: text/xml; charset=utf-8');
        $dom = new DomDocument('1.0', 'utf-8');
        $node = $dom->createElement('task');
        $node->setAttribute('status', $task->status);
        $dom->appendChild($node);
        die($dom->saveXML());
    }
    $ret = $task->get_AllInfos();
    header('Content-Type: text/xml; charset=utf-8');
    die($ret['stdout']);
}
コード例 #10
0
ファイル: MyExtention.php プロジェクト: netaspid/ikea-ws
 static function CreateXML($DataArray)
 {
     $dom = new DomDocument('1.0');
     $element = $dom->appendChild($dom->createElement('element'));
     $elementObject = $element->appendChild($dom->createElement('elementObject'));
     foreach ($DataArray as $key => $value) {
         if (!is_array($value)) {
             $param = $elementObject->appendChild($dom->createElement(MyExtention::xml_check($key)));
             $param->appendChild($dom->CreateTextNode(MyExtention::xml_check($value)));
         } elseif ($key == "images") {
             $elementImages = $elementObject->appendChild($dom->createElement(MyExtention::xml_check($key)));
             foreach ($value as $subkey => $subvalue) {
                 $elementImage = $elementImages->appendChild($dom->createElement('image'));
                 $elementImage->appendChild($dom->CreateTextNode("http://www.ikea.com" . MyExtention::xml_check($subvalue)));
             }
         } elseif ($key == "category") {
             $elementCategories = $elementObject->appendChild($dom->createElement('elementCategories'));
             foreach ($value as $subkey => $subvalue) {
                 if ($subvalue != "Домой") {
                     $elementCategory = $elementCategories->appendChild($dom->createElement('elementCategory'));
                     $elementCategory->appendChild($dom->CreateTextNode(MyExtention::xml_check($subvalue)));
                 }
             }
         }
     }
     $dom->formatOutput = true;
     $resultXML = $dom->saveXML();
     return $resultXML;
 }
コード例 #11
0
ファイル: BlogPost.php プロジェクト: chriswells0/cwa-blog
 public function getPreview($elements)
 {
     if (!isset($this->preview)) {
         if (!isset($elements)) {
             $elements = 2;
         }
         // Get just the text (no markup) from a node using $node->textContent.
         // Compare the textContent value to the one returned by $node->nodeValue.
         libxml_use_internal_errors(true);
         $dom = new DomDocument();
         $dom->preserveWhiteSpace = false;
         $dom->loadHTML('<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head><body>' . $this->Body . '</body></html>');
         $dom->normalize();
         $nodes = $dom->getElementsByTagName("body")->item(0)->childNodes;
         $elementCount = 0;
         $this->preview = '';
         foreach ($nodes as $node) {
             if ($node->nodeType === XML_ELEMENT_NODE) {
                 $this->preview .= $dom->saveXML($node);
                 $elementCount++;
                 if ($elementCount === $elements) {
                     break;
                 }
             }
         }
         // Carriage returns in the XML prevent the markup from validating. -- cwells
         $this->preview = str_replace('&#13;', '', $this->preview);
     }
     return $this->preview;
 }
コード例 #12
0
ファイル: napojak.php プロジェクト: zcsevcik/edu
function getXmlNapojak()
{
    $d = new DomDocument('1.0', 'utf-8');
    $root_e = $d->createElement('napojak');
    foreach (MyDB::getInstance()->getResults(MyDB::getQuery(SELECT_NAPOJAK_KAT)) as $kat) {
        $kat_e = $d->createElement('kategorie');
        $kat_e->setAttribute('id', $kat['id']);
        $kat_e->setAttribute('nazev', $kat['nazev']);
        $kat_e->setAttribute('popis', $kat['popis']);
        $param = array(':kat_id' => $kat['id']);
        foreach (MyDB::getInstance()->getParamResults(MyDB::getQuery(SELECT_NAPOJAK), $param) as $row) {
            $item_e = $d->createElement('item');
            $item_e->setAttribute('id', $row['id']);
            $item_e->setAttribute('nazev', $row['nazev']);
            $item_e->setAttribute('popis', $row['popis']);
            $item_e->setAttribute('cena', $row['cena']);
            $en = (bool) $row['en'] ? "true" : "false";
            $item_e->setAttribute('en', $en);
            $kat_e->appendChild($item_e);
        }
        $root_e->appendChild($kat_e);
    }
    $d->appendChild($root_e);
    return $d->saveXML();
}
コード例 #13
0
ファイル: wpt_feeds.php プロジェクト: henk23/wp-theatre
 function upcoming_events()
 {
     header('Content-Type: ' . feed_content_type('rss-http') . '; charset=' . get_option('blog_charset'), true);
     $xml = new DomDocument();
     $xml->loadXML($this->get_upcoming_events());
     echo $xml->saveXML();
 }
コード例 #14
0
ファイル: CheckstylePrinter.php プロジェクト: ablyler/phan
 /** flush printer buffer */
 public function flush()
 {
     $document = new \DomDocument('1.0', 'ISO-8859-15');
     $checkstyle = new \DOMElement('checkstyle');
     $document->appendChild($checkstyle);
     $checkstyle->appendChild(new \DOMAttr('version', '6.5'));
     // Write each file to the DOM
     foreach ($this->files as $file_name => $error_list) {
         $file = new \DOMElement('file');
         $checkstyle->appendChild($file);
         $file->appendChild(new \DOMAttr('name', $file_name));
         // Write each error to the file
         foreach ($error_list as $error_map) {
             $error = new \DOMElement('error');
             $file->appendChild($error);
             // Write each element of the error as an attribute
             // of the error
             foreach ($error_map as $key => $value) {
                 $error->appendChild(new \DOMAttr($key, (string) $value));
             }
         }
     }
     $this->output->write($document->saveXML());
     $this->files = [];
 }
コード例 #15
0
function hal_parse($url)
{
    $url = trim(html_entity_decode($url), "\"' ");
    $infos = parse_url($url);
    $ip = gethostbyname($infos['host']);
    if ($ip != '193.48.96.10') {
        spip_log("Url invalid", _LOG_ERREUR);
        return;
    }
    spip_log(sprintf("[hal_parse] init_http(%s)", $url), _LOG_DEBUG);
    $content = recuperer_page($url);
    spip_log(sprintf("[hal_parse] init_http(%s): Done", $url), _LOG_DEBUG);
    $dom = new DomDocument('1.0', 'UTF-8');
    $dom->preserveWhiteSpace = false;
    $str = mb_convert_encoding($content, "HTML-ENTITIES");
    @$dom->loadHTML($str);
    $xpath = new DOMXpath($dom);
    $entries = $xpath->query('//div[@id="res_script"]');
    if ($entries->length == 0) {
        spip_log("No tag found ...", _LOG_ERREUR);
        return;
    }
    $res_script = $dom->saveXML($entries->item(0));
    return $res_script;
}
コード例 #16
0
function errorHandler($errno, $errstr, $errfile, $errline, $errcontext)
{
    # capture some additional information
    $agent = $_SERVER['HTTP_USER_AGENT'];
    $ip = $_SERVER['REMOTE_ADDR'];
    $referrer = $_SERVER['HTTP_REFERER'];
    $dt = date("Y-m-d H:i:s (T)");
    # grab email info if available
    global $err_email, $err_user_name;
    # use this to email problem to maintainer if maintainer info is set
    if (isset($err_user_name) && isset($err_email)) {
    }
    # Write error message to user with less details
    $xmldoc = new DomDocument('1.0');
    $xmldoc->formatOutput = true;
    # Set root
    $root = $xmldoc->createElement("error_handler");
    $root = $xmldoc->appendChild($root);
    # Set child
    $occ = $xmldoc->createElement("error");
    $occ = $root->appendChild($occ);
    # Write error message
    $child = $xmldoc->createElement("error_message");
    $child = $occ->appendChild($child);
    $fvalue = $xmldoc->createTextNode("Your request has returned an error: " . $errstr);
    $fvalue = $child->appendChild($fvalue);
    $xml_string = $xmldoc->saveXML();
    echo $xml_string;
    # exit request
    exit;
}
コード例 #17
0
ファイル: Request.php プロジェクト: camigreen/ttop
 /**
  * Build the validate address request
  * @return string
  * @throws \SimpleUPS\Api\MissingParameterException
  */
 public function buildXml()
 {
     if (serialize($this->getAddress()) == serialize(new Address())) {
         throw new MissingParameterException('Address requires a Country code, Postal code, and either a City or State\\Province code');
     }
     if ($this->getAddress()->getCountryCode() === null) {
         throw new MissingParameterException('Address requires a Country code');
     }
     if ($this->getAddress()->getPostalCode() === null) {
         throw new MissingParameterException('Address requires a Postal code');
     }
     $dom = new \DomDocument('1.0');
     $dom->formatOutput = $this->getDebug();
     $dom->appendChild($addressRequest = $dom->createElement('AddressValidationRequest'));
     $addressRequestLang = $dom->createAttribute('xml:lang');
     $addressRequestLang->value = parent::getXmlLang();
     $addressRequest->appendChild($request = $dom->createElement('Request'));
     $request->appendChild($transactionReference = $dom->createElement('TransactionReference'));
     $transactionReference->appendChild($dom->createElement('CustomerContext', $this->getCustomerContext()));
     $transactionReference->appendChild($dom->createElement('XpciVersion', $this->getXpciVersion()));
     $request->appendChild($dom->createElement('RequestAction', 'AV'));
     $addressRequest->appendChild($address = $dom->createElement('Address'));
     if ($this->getAddress()->getCity() != null) {
         $address->appendChild($dom->createElement('City', $this->getAddress()->getCity()));
     }
     if ($this->getAddress()->getStateProvinceCode() != null) {
         $address->appendChild($dom->createElement('StateProvinceCode', $this->getAddress()->getStateProvinceCode()));
     }
     if ($this->getAddress()->getPostalCode() != null) {
         $address->appendChild($dom->createElement('PostalCode', $this->getAddress()->getPostalCode()));
     }
     $address->appendChild($dom->createElement('CountryCode', $this->getAddress()->getCountryCode()));
     $xml = parent::buildAuthenticationXml() . $dom->saveXML();
     return $xml;
 }
コード例 #18
0
ファイル: response.php プロジェクト: nattomi/ReportGenerator
 static function response($status, $status_message, $domdocument = null)
 {
     $dom = new DomDocument('1.0', 'UTF-8');
     $results = $dom->appendChild($dom->createElement('response'));
     $results->appendChild($dom->createElement('status', $status));
     $results->appendChild($dom->createElement('status_message', $status_message));
     if (is_null($domdocument)) {
         $domdocument = new DomDocument('1.0', 'UTF-8');
         $domdocument->appendChild($domdocument->createElement('data'));
     }
     if ($domdocument->documentElement->nodeName === 'data') {
         $newdom = $domdocument;
     } else {
         $newdom = new DOMDocument('1.0', 'UTF-8');
         $data = $newdom->appendChild($newdom->createElement('data'));
         foreach ($domdocument->documentElement->childNodes as $domElement) {
             $domNode = $newdom->importNode($domElement, true);
             $data->appendChild($domNode);
         }
     }
     $import = $dom->importNode($newdom->documentElement, TRUE);
     $results->appendChild($import);
     $dom->formatOutput = true;
     echo $dom->saveXML();
 }
コード例 #19
0
 /**
  * Serialize an associative array of pci properties into a pci xml
  *
  * @param array $properties
  * @param string $ns
  * @return string
  */
 private function serializePortableProperties($properties, $ns = '', $nsUri = '', $name = null, $element = null)
 {
     $document = null;
     $result = '';
     if ($element === null) {
         $document = new \DomDocument();
         $element = $ns ? $document->createElementNS($nsUri, $ns . ':properties') : $document->createElement('properties');
         $document->appendChild($element);
     } else {
         $newElement = $ns ? $element->ownerDocument->createElementNS($nsUri, $ns . ':properties') : $element->ownerDocument->createElement('properties');
         $element->appendChild($newElement);
         $element = $newElement;
     }
     if ($name !== null) {
         $element->setAttribute('key', $name);
     }
     foreach ($properties as $name => $value) {
         if (is_array($value)) {
             $this->serializePortableProperties($value, $ns, $nsUri, $name, $element);
         } else {
             $entryElement = $ns ? $element->ownerDocument->createElementNS($nsUri, $ns . ':entry') : $element->ownerDocument->createElementNS('entry');
             $entryElement->setAttribute('key', $name);
             $entryElement->appendChild(new \DOMText($value));
             $element->appendChild($entryElement);
         }
     }
     if ($document !== null) {
         foreach ($document->childNodes as $node) {
             $result .= $document->saveXML($node);
         }
     }
     return $result;
 }
コード例 #20
0
ファイル: Output.php プロジェクト: visualweber/appzf1
 /**
  * Convert a tree array (with depth) into a hierarchical XML string.
  *
  * @param $nodes|array   Array with depth value.
  *
  * @return string
  */
 public function toXml(array $nodes)
 {
     $xml = new DomDocument('1.0');
     $xml->preserveWhiteSpace = false;
     $root = $xml->createElement('root');
     $xml->appendChild($root);
     $depth = 0;
     $currentChildren = array();
     foreach ($nodes as $node) {
         $element = $xml->createElement('element');
         $element->setAttribute('id', $node['id']);
         $element->setAttribute('name', $node['name']);
         $element->setAttribute('lft', $node['lft']);
         $element->setAttribute('rgt', $node['rgt']);
         $children = $xml->createElement('children');
         $element->appendChild($children);
         if ($node['depth'] == 0) {
             // Handle root
             $root->appendChild($element);
             $currentChildren[0] = $children;
         } elseif ($node['depth'] > $depth) {
             // is a new sub level
             $currentChildren[$depth]->appendChild($element);
             $currentChildren[$node['depth']] = $children;
         } elseif ($node['depth'] == $depth || $node['depth'] < $depth) {
             // is at the same level
             $currentChildren[$node['depth'] - 1]->appendChild($element);
         }
         $depth = $node['depth'];
     }
     return $xml->saveXML();
 }
コード例 #21
0
 function teste()
 {
     $xml = new DomDocument("1.0", "UTF-8");
     /*
     $container = $xml->createElement('container', 'tkjasdkfjal');
     $container = $xml->appendChild($container);
     
     
     $sale = $xml->createElement('sale');
     $sale = $container->appendChild($sale);
     
     
     $item = $xml->createElement('item', 'Television');
     $item = $sale->appendChild($item);
     
     $price = $xml->createElement('price', '$100');
     $price = $sale->appendChild($price);
     */
     $cadastro = $xml->createElement('Cadastro');
     $cadastro = $xml->appendChild($cadastro);
     $pessoa = $xml->createElement('Pessoa');
     $pessoa = $cadastro->appendChild($pessoa);
     $nome = $xml->createElement('nome', 'Rodrigo');
     $pessoa->appendChild($nome);
     $situacao = $xml->createElement('situacao', 'fudido');
     $pessoa->appendChild($situacao);
     $xml->FormatOutput = true;
     $string_value = $xml->saveXML();
     $xml->save('xml/teste.xml');
     echo 'xml criado, chupa mundo';
     exit;
     //$xml = Xml::build('<example>text</example>', array('app/teste.xml'));
     //exit;
 }
コード例 #22
0
ファイル: Xmp.php プロジェクト: dchesterton/image
 /**
  * @return string
  */
 public function getString()
 {
     // ensure the xml has the required xpacket processing instructions
     $result = $this->xpath->query('/processing-instruction(\'xpacket\')');
     $hasBegin = $hasEnd = false;
     /** @var $item \DOMProcessingInstruction */
     foreach ($result as $item) {
         // do a quick check if the processing instruction contains 'begin' or 'end'
         if (false !== stripos($item->nodeValue, 'begin')) {
             $hasBegin = true;
         } elseif (false !== stripos($item->nodeValue, 'end')) {
             $hasEnd = true;
         }
     }
     if (!$hasBegin) {
         $this->dom->insertBefore($this->dom->createProcessingInstruction('xpacket', "begin=\"\" id=\"W5M0MpCehiHzreSzNTczkc9d\""), $this->dom->documentElement);
     }
     if (!$hasEnd) {
         $this->dom->appendChild($this->dom->createProcessingInstruction('xpacket', 'end="w"'));
         // append to end
     }
     // ensure all rdf:Description elements have an rdf:about attribute
     $descriptions = $this->xpath->query('//rdf:Description');
     for ($i = 0; $i < $descriptions->length; $i++) {
         /** @var \DOMElement $desc */
         $desc = $descriptions->item($i);
         $desc->setAttributeNS(self::RDF_NS, 'rdf:about', $this->about);
     }
     return $this->dom->saveXML();
 }
コード例 #23
0
ファイル: Template.php プロジェクト: headinbeds/Transphporm
 /** Prints out the current DomDocument as HTML */
 private function printDocument(\DomDocument $doc)
 {
     $output = '';
     foreach ($doc->documentElement->childNodes as $node) {
         $output .= $doc->saveXML($node, LIBXML_NOEMPTYTAG);
     }
     return $output;
 }
コード例 #24
0
ファイル: Prototype.php プロジェクト: hametuha/hamepub
 /**
  * Get XML string in pretty format
  *
  * @return string
  */
 public function getXML()
 {
     $doc = new \DomDocument('1.0');
     $doc->preserveWhiteSpace = false;
     $doc->formatOutput = true;
     $doc->loadXML($this->dom->asXml());
     return $doc->saveXML();
 }
コード例 #25
0
 private function dumpXml($xml)
 {
     $doc = new DomDocument('1.0', 'UTF-8');
     $doc->loadXML($xml);
     $doc->preserveWhiteSpace = true;
     $doc->formatOutput = true;
     echo $doc->saveXML();
 }
コード例 #26
0
ファイル: ReniecSoapCli.php プロジェクト: luisfarfan/helpdesk
 function __doRequest($request, $location, $action, $version, $one_way = NULL)
 {
     $dom = new DomDocument('1.0', 'UTF-8');
     $dom->preserveWhiteSpace = false;
     $dom->loadXML($this->getXMLData());
     $request = $dom->saveXML();
     return parent::__doRequest($request, $location, $action, $version, $one_way);
 }
コード例 #27
0
ファイル: logout.php プロジェクト: skdong/nfs-ovd
function return_error($errno_, $errstr_)
{
    $dom = new DomDocument('1.0', 'utf-8');
    $node = $dom->createElement('error');
    $node->setAttribute('id', $errno_);
    $node->setAttribute('message', $errstr_);
    $dom->appendChild($node);
    return $dom->saveXML();
}
コード例 #28
0
ファイル: export.php プロジェクト: annguyenit/getdeal
/**
 * Export Table Data
 *
 * @access public
 * @since 1.0.0
 *
 * @param array $options
 * @param string $table_name
 *
 * @return file
 */
function templ_option_tree_export_xml($options, $table_name)
{
    global $wpdb;
    // create doctype
    $dom = new DomDocument("1.0");
    $dom->formatOutput = true;
    header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
    header("Pragma: no-cache ");
    header("Content-Type: text/plain");
    header('Content-Disposition: attachment; filename="theme-options-' . date("Y-m-d") . '.xml"');
    // create root element
    $root = $dom->createElement($table_name);
    $root = $dom->appendChild($root);
    foreach ($options as $value) {
        // create root element
        $child = $dom->createElement('row');
        $child = $root->appendChild($child);
        // ID
        $item = $dom->createElement('id');
        $item = $child->appendChild($item);
        $text = $dom->createTextNode($value->id);
        $text = $item->appendChild($text);
        // Item ID
        $item = $dom->createElement('item_id');
        $item = $child->appendChild($item);
        $text = $dom->createTextNode($value->item_id);
        $text = $item->appendChild($text);
        // Item Title
        $item = $dom->createElement('item_title');
        $item = $child->appendChild($item);
        $text = $dom->createTextNode($value->item_title);
        $text = $item->appendChild($text);
        // Item Description
        $item = $dom->createElement('item_desc');
        $item = $child->appendChild($item);
        $text = $dom->createTextNode($value->item_desc);
        $text = $item->appendChild($text);
        // Item Type
        $item = $dom->createElement('item_type');
        $item = $child->appendChild($item);
        $text = $dom->createTextNode($value->item_type);
        $text = $item->appendChild($text);
        // Item Options
        $item = $dom->createElement('item_options');
        $item = $child->appendChild($item);
        $text = $dom->createTextNode($value->item_options);
        $text = $item->appendChild($text);
        // Item Sort
        $item = $dom->createElement('item_sort');
        $item = $child->appendChild($item);
        $text = $dom->createTextNode($value->item_sort);
        $text = $item->appendChild($text);
    }
    // save and display tree
    echo $dom->saveXML();
    die;
}
コード例 #29
0
ファイル: XmlLoader.php プロジェクト: leoht/erlenmeyer
 public function load(Registry $registry)
 {
     $document = new \DomDocument($this->filePath);
     $this->data = $document->saveXML();
     var_dump($this->data);
     die;
     $this->loadStrategies($registry);
     $this->loadFeatures($registry);
 }
コード例 #30
-1
 function __doRequest($request, $location, $action, $version)
 {
     $dom = new DomDocument('1.0', 'UTF-8');
     $dom->preserveWhiteSpace = false;
     $dom->loadXML($request);
     $hdr = $dom->createElement('soapenv:Header');
     $secNode = $dom->createElement("wsse:Security");
     $secNode->setAttribute("soapenv:mustUnderstand", "1");
     $secNode->setAttribute("xmlns:wsse", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd");
     $usernameTokenNode = $dom->createElement("wsse:UsernameToken");
     $usernameTokenNode->setAttribute("wsu:Id", "UsernameToken-1");
     $usernameTokenNode->setAttribute("xmlns:wsu", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd");
     $usrNode = $dom->createElement("wsse:Username");
     $usrNode->appendChild($dom->createTextNode(WS_USER));
     $pwdNode = $dom->createElement("wsse:Password");
     $pwdNode->setAttribute("Type", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText");
     $pwdNode->appendchild($dom->createTextnode(WS_PWD));
     $usernameTokenNode->appendChild($usrNode);
     $usernameTokenNode->appendChild($pwdNode);
     $secNode->appendChild($usernameTokenNode);
     $hdr->appendChild($secNode);
     $dom->documentElement->insertBefore($hdr, $dom->documentElement->firstChild);
     $request = $dom->saveXML();
     $request = str_replace("SOAP-ENV", "soapenv", $request);
     $request = str_replace("ns1", "cgt", $request);
     $request = str_replace('<?xml version="1.0" encoding="UTF-8"?>', '', $request);
     //  echo "Este es el nuevo XML: " . print_r($request, true);
     return parent::__doRequest($request, $location, $action, $version);
 }