Ejemplo n.º 1
1
 function props_to_xml()
 {
     # make the source xml
     # make doc and root
     $xml = new DomDocument();
     $root = $xml->createElement('request');
     $root->setAttribute('controller', params('controller'));
     $root->setAttribute('action', params('action'));
     $root = $xml->appendChild($root);
     # unpack the props into xml
     foreach ($this->props as $k => $v) {
         # if it will become xml, do that, otherwise make a dumb tag
         if (is_object($v) && method_exists($v, 'to_xml')) {
             $obj_xml = $v->to_xml(array(), true, true);
             $obj_xml = $xml->importNode($obj_xml->documentElement, true);
             $root->appendChild($obj_xml);
         } else {
             $node = $xml->createElement($k);
             if (strpos($v, '<') !== false || strpos($v, '>') !== false || strpos($v, '&') !== false) {
                 $cdata = $xml->createCDATASection($v);
             } else {
                 $cdata = $xml->createTextNode($v);
             }
             $node->appendChild($cdata);
             $node = $root->appendChild($node);
         }
     }
     return $xml;
 }
Ejemplo n.º 2
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;
}
Ejemplo n.º 3
0
 /**
  * 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();
 }
Ejemplo n.º 4
0
 /**
  * Convert an Array to XML
  * @param string $root_node - name of the root node to be converted
  * @param array $data - array to be converted
  * @throws \Exception
  * @return \DOMNode
  */
 protected function convertArrayToXml($root_node, $data = array())
 {
     if (!$this->isValidTagName($root_node)) {
         throw new \Exception('Array to XML Conversion - Illegal character in element name: ' . $root_node);
     }
     $node = $this->xml->createElement($root_node);
     if (is_scalar($data)) {
         $node->appendChild($this->xml->createTextNode($this->bool2str($data)));
     }
     if (is_array($data)) {
         foreach ($data as $key => $value) {
             $this->current_node_name = $root_node;
             $key = is_numeric($key) ? Inflector::singularize($this->current_node_name) : $key;
             $node->appendChild($this->convertArrayToXml($key, $value));
             unset($data[$key]);
         }
     }
     if (is_object($data)) {
         // Catch toString objects, and datetime. Note Closure's will fall into here
         if (method_exists($data, '__toString')) {
             $node->appendChild($this->xml->createTextNode($data->__toString()));
         } elseif ($data instanceof \DateTime) {
             $node->appendChild($this->xml->createTextNode($data->format(\DateTime::ISO8601)));
         } else {
             throw new \Exception('Invalid data type used in Array to XML conversion. Must be object of \\DateTime or implement __toString()');
         }
     }
     return $node;
 }
Ejemplo n.º 5
0
 /**
  * Build the validate address request
  * @internal
  * @return string
  * @throws \SimpleUPS\Api\MissingParameterException
  */
 public function buildXml()
 {
     if ($this->getShipment()->getDestination() == null) {
         throw new MissingParameterException('Shipment destination is missing');
     }
     $dom = new \DomDocument('1.0');
     $dom->formatOutput = $this->getDebug();
     $dom->appendChild($ratingRequest = $dom->createElement('RatingServiceSelectionRequest'));
     $addressRequestLang = $dom->createAttribute('xml:lang');
     $addressRequestLang->value = parent::getXmlLang();
     $ratingRequest->appendChild($request = $dom->createElement('Request'));
     $request->appendChild($transactionReference = $dom->createElement('TransactionReference'));
     $transactionReference->appendChild($dom->createElement('CustomerContext', $this->getCustomerContext()));
     $request->appendChild($dom->createElement('RequestAction', 'Rate'));
     $request->appendChild($dom->createElement('RequestOption', 'Shop'));
     //@todo test with "Rate" as setting to determine difference
     $ratingRequest->appendChild($pickupType = $dom->createElement('PickupType'));
     $pickupType->appendChild($shipmentType = $dom->createElement('Code', $this->getPickupType()));
     if ($this->getRateType() != null) {
         $ratingRequest->appendChild($customerClassification = $dom->createElement('CustomerClassification'));
         $customerClassification->appendChild($dom->createElement('Code', $this->getRateType()));
     }
     // Shipment
     $shipment = $this->getShipment();
     $shipment->setShipper(UPS::getShipper());
     $ratingRequest->appendChild($shipment->toXml($dom));
     $xml = parent::buildAuthenticationXml() . $dom->saveXML();
     return $xml;
 }
Ejemplo n.º 6
0
 protected function prepareData()
 {
     $v4b43b0aee35624cd95b910189b3dc231 = $this->reader;
     $v9a09b4dfda82e3e665e31092d1c3ec8d = new DomDocument();
     $v5118e2d6cb8d101c16049b9cf18de377 = $v9a09b4dfda82e3e665e31092d1c3ec8d->createElement("yml_catalog");
     $v9a09b4dfda82e3e665e31092d1c3ec8d->appendChild($v5118e2d6cb8d101c16049b9cf18de377);
     $v63a9f0ea7bb98050796b649e85481845 = $v9a09b4dfda82e3e665e31092d1c3ec8d->createElement("shop");
     $v5118e2d6cb8d101c16049b9cf18de377->appendChild($v63a9f0ea7bb98050796b649e85481845);
     $v7a86c157ee9713c34fbd7a1ee40f0c5a = $this->offset;
     while ($v4b43b0aee35624cd95b910189b3dc231->read() && $v4b43b0aee35624cd95b910189b3dc231->name != 'categories') {
         if ($v4b43b0aee35624cd95b910189b3dc231->nodeType != XMLReader::ELEMENT) {
             continue;
         }
         if ($v4b43b0aee35624cd95b910189b3dc231->name == 'yml_catalog' || $v4b43b0aee35624cd95b910189b3dc231->name == 'shop') {
             continue;
         }
         $v8e2dcfd7e7e24b1ca76c1193f645902b = $v4b43b0aee35624cd95b910189b3dc231->expand();
         $v63a9f0ea7bb98050796b649e85481845->appendChild($v8e2dcfd7e7e24b1ca76c1193f645902b);
     }
     $v4757fe07fd492a8be0ea6a760d683d6e = 0;
     while ($v4b43b0aee35624cd95b910189b3dc231->read() && $v4757fe07fd492a8be0ea6a760d683d6e < $v7a86c157ee9713c34fbd7a1ee40f0c5a) {
         if ($v4b43b0aee35624cd95b910189b3dc231->nodeType != XMLReader::ELEMENT) {
             continue;
         }
         if ($v4b43b0aee35624cd95b910189b3dc231->name == 'category' || $v4b43b0aee35624cd95b910189b3dc231->name == 'offer') {
             $v4757fe07fd492a8be0ea6a760d683d6e++;
         }
     }
     $this->offset += $v4757fe07fd492a8be0ea6a760d683d6e;
     $this->doc = $v9a09b4dfda82e3e665e31092d1c3ec8d;
 }
Ejemplo n.º 7
0
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();
}
 /**
  * Generate the form. The dates are not fixed, so we can't write an XML file for this.
  * Each date has a checkbox, defining whether the leader is available (ticked) or not
  * TODO: Display weekends and bank holidays (bank holidays currently not in database)
  */
 public function getForm($data = array(), $loadData = true)
 {
     if (!isset($this->form)) {
         // Looks like I have to generate the XML for the form?! WTF? Hurr durr OOP is hard for our programmer users durr.
         $XMLDoc = new DomDocument("1.0", "UTF-8");
         $formXML = $XMLDoc->createElement("form");
         $formXML->setAttribute("name", "manageavailability");
         $XMLDoc->appendChild($formXML);
         $fieldsetXML = $XMLDoc->createElement("fieldset");
         $fieldsetXML->setAttribute("name", "availability");
         $formXML->appendChild($fieldsetXML);
         $progNumXML = $XMLDoc->createElement("field");
         $progNumXML->setAttribute("type", "hidden");
         $progNumXML->setAttribute("name", "programmeid");
         $progNumXML->setAttribute("default", $this->programme->id);
         $fieldsetXML->appendChild($progNumXML);
         foreach ($this->programme->getLeaderAvailability($this->leader->id) as $date => $available) {
             $field = $XMLDoc->createElement("field");
             $field->setAttribute("type", "checkbox");
             $field->setAttribute("name", "availability_" . $date);
             $field->setAttribute("label", strftime("%A %e %B %Y", $date));
             $field->setAttribute("value", 1);
             $field->setAttribute("default", $available ? 1 : 0);
             $fieldsetXML->appendChild($field);
         }
         $this->form = $this->loadForm("com_swg_leaderutils.manageavailability", $XMLDoc->saveXML(), array('control' => 'jform', 'load_data' => false));
     }
     return $this->form;
 }
function create_xml_droits($array_section)
{
    $dom_document = new DomDocument("1.0", "UTF-8");
    $dom_document->formatOutput = true;
    $root = $dom_document->createElement("droits");
    $root = $dom_document->appendChild($root);
    foreach ($array_section as $nom_section => $droits) {
        $section = $dom_document->createElement("section");
        $section->setAttribute("name", $nom_section);
        $section = $root->appendChild($section);
        foreach ($droits as $nom_droit => $type_droit) {
            $droit = $dom_document->createElement("droit");
            $droit = $section->appendChild($droit);
            $nom = $dom_document->createElement("name");
            $nom = $droit->appendChild($nom);
            $textNom = $dom_document->createTextNode($nom_droit);
            $textNom = $nom->appendChild($textNom);
            $type = $dom_document->createElement("type");
            $type = $droit->appendChild($type);
            $textType = $dom_document->createTextNode($type_droit);
            $textType = $type->appendChild($textType);
        }
    }
    $dom_document->save(PATH_ROOT . 'inc/droits.xml');
}
Ejemplo n.º 10
0
 public function _toHtml()
 {
     $this->_checkRequired();
     $info = $this->getInfo();
     $certain = $info['certain'];
     $dom = new DomDocument();
     $dom->preserveWhitespace = false;
     $block = $dom->createElement('block');
     $attr = $dom->createAttribute('type');
     $attr->value = $this->getAlias();
     $block->appendChild($attr);
     $dom->appendChild($block);
     $output = simplexml_load_string('<block />');
     foreach ($certain as $method) {
         $block->appendChild($dom->createComment("\n     " . $this->_getDocumentation($method) . "\n  "));
         $dom_action = $dom->createElement('action');
         $block->appendChild($dom_action);
         $dom_attr = $dom->createAttribute('method');
         $dom_attr->value = $method->getName();
         $dom_action->appendChild($dom_attr);
         $this->addParamsToDomActionNodeFromReflectionMethod($dom, $dom_action, $method);
         //$action = $this->addParamsToActionNodeFromReflectionMethod($action, $method);
     }
     $dom->formatOutput = true;
     return $this->_extraXmlFormatting($dom->saveXml());
 }
Ejemplo n.º 11
0
 /**
  * @param $nameRoot - имя корня xml
  * @param $nameBigElement - имя узла в который записываются данные из массива $data
  * @param $data - массив с данными выгружеными из таблицы
  */
 function createXml($nameRoot, $nameBigElement, $data)
 {
     // создает XML-строку и XML-документ при помощи DOM
     $dom = new DomDocument($this->version, $this->encode);
     // добавление корня
     $root = $dom->appendChild($dom->createElement($nameRoot));
     // отбираем названия полей таблицы
     foreach (array_keys($data[0]) as $k) {
         if (is_string($k)) {
             $key[] = $k;
         }
     }
     // формируем элементы с данными
     foreach ($data as $d) {
         //добавление элемента $nameBigElement в корень
         $bigElement = $root->appendChild($dom->createElement($nameBigElement));
         foreach ($key as $k) {
             $element = $bigElement->appendChild($dom->createElement($k));
             $element->appendChild($dom->createTextNode($d[$k]));
         }
     }
     // сохраняем результат в файл
     $dom->save('format/' . $this->nameFile);
     unset($dom);
 }
 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;
 }
Ejemplo n.º 13
0
 /**
  * Constructor for AppKitXmlTag
  * @param string $tag_name
  * @param string $content
  */
 public function __construct($tag_name, $content = null)
 {
     $this->dom = new DOMDocument('1.0');
     $this->tag = $this->dom->createElement($tag_name);
     if ($content !== null) {
         $this->setContent($content);
     }
 }
Ejemplo n.º 14
0
 /**
  * Constructor
  * @return unknown_type
  */
 public function __construct()
 {
     $this->_document = new DOMDocument();
     //create structute /xml/content
     $this->_document->appendChild($this->_document->createElement('xml'));
     $this->_contentNode = $this->_document->createElement('content');
     $this->_document->documentElement->appendChild($this->_contentNode);
 }
Ejemplo n.º 15
0
/**
 * This function appends expires_at and job_description_format tags into RSS
 * <item> tag. 
 * 
 * Function is applied once for each <item> in the feed and the additional data
 * is appended to the end of "item".
 * 
 * @param DomElement $item      http://php.net/manual/en/class.domelement.php
 * @param DomDocument $rss      http://php.net/manual/en/class.domdocument.php
 * @param Wpjb_Model_Job $job   Job currently rendered to XML
 * @return DomElement           Modified DomElement object
 */
function feeds_api_rss($item, $rss, $job)
{
    // Using default fields
    $item->appendChild($rss->createElement("expires_at", esc_html($job->job_expires_at)));
    // Using meta fields
    $item->appendChild($rss->createElement("job_description_format", esc_html($job->meta->job_description_format->value())));
    // Make sure to return $item
    return $item;
}
Ejemplo n.º 16
0
 /**
  * Get service as XML
  * @internal
  *
  * @param \DomDocument $dom
  *
  * @return \DOMElement
  */
 public function toXml(\DomDocument $dom)
 {
     $shipper = $dom->createElement('Service');
     if ($this->getCode() != null) {
         $shipper->appendChild($dom->createElement('Code', $this->getCode()));
     }
     if ($this->getDescription() != null) {
         $shipper->appendChild($dom->createElement('Description', $this->getDescription()));
     }
     return $shipper;
 }
Ejemplo n.º 17
0
 public function getAsXML()
 {
     $doc = new DomDocument();
     $root = $doc->createElement('CD');
     $root = $doc->appendChild($root);
     $title = $doc->createElement('TITLE', $this->title);
     $title = $root->appendChild($title);
     $band = $doc->createElement('BAND', $this->band);
     $band = $root->appendChild($band);
     return $doc->saveXML();
 }
Ejemplo n.º 18
0
 public function get(CDusersStrategy $cd)
 {
     $doc = new DomDocument();
     $root = $doc->createElement("CD");
     $root = $doc->appendChild($root);
     $title = $doc->createElement("TTILE", $cd->title);
     $title = $root->appendChild($title);
     $band = $doc->createElement("BAND", $cd->band);
     $band = $root->appendChild($band);
     return $doc->saveXML();
 }
Ejemplo n.º 19
0
function getXmlNews()
{
    $d = new DomDocument('1.0', 'utf-8');
    $root_e = $d->createElement('news');
    foreach (MyDB::getInstance()->getResults(MyDB::getQuery(SELECT_NEWS)) as $row) {
        $item_e = $d->createElement('item', $row['obsah']);
        $item_e->setAttribute('date', $row['datum']);
        $root_e->appendChild($item_e);
    }
    $d->appendChild($root_e);
    return $d->saveXML();
}
Ejemplo n.º 20
0
 private function createBody(DomDocument $document, DOMXPath $xpath)
 {
     $xliff = $xpath->query('//xliff')->item(0) ?: $document->createElement('xliff');
     $xliff->setAttribute('xmlns', 'urn:oasis:names:tc:xliff:document:1.2');
     $xliff->setAttribute('version', '1.2');
     $document->appendChild($xliff);
     $file = $xpath->query('//xliff:file')->item(0) ?: $document->createElement('file');
     $xliff->appendChild($file);
     $body = $document->createElement('body');
     $file->appendChild($body);
     return $body;
 }
Ejemplo n.º 21
0
 /**
  * @see \DrestCommon\Error\Response\ResponseInterface::render()
  */
 public function render()
 {
     $xml = new \DomDocument('1.0', 'UTF-8');
     $xml->formatOutput = true;
     $root = $xml->createElement('error');
     $xml->appendChild($root);
     foreach ($this->getMessages() as $message) {
         $node = $xml->createElement('message', $message);
         $root->appendChild($node);
     }
     return $xml->saveXML();
 }
Ejemplo n.º 22
0
 /**
  * General manipulate wrapper method.
  *
  *  @param string $input The XML fragment to be manipulated. We are only
  *     interested in the <extension><CSVData> fragment added in the
  *     MIK mappings file.
  *
  * @return string
  *     One of the manipulated XML fragment, the original input XML if the
  *     input is not the fragment we are interested in, or an empty string,
  *     which as the effect of removing the empty <extension><CSVData>
  *     fragement from our MODS (if there was an error, for example, we don't
  *     want empty extension elements in our MODS documents).
  */
 public function manipulate($input)
 {
     $dom = new \DomDocument();
     $dom->loadxml($input, LIBXML_NSCLEAN);
     // Test to see if the current fragment is <extension><CSVData>.
     $xpath = new \DOMXPath($dom);
     $csvdatas = $xpath->query("//extension/CSVData");
     // There should only be one <CSVData> fragment in the incoming
     // XML. If there is 0 or more than 1, return the original.
     if ($csvdatas->length === 1) {
         $csvdata = $csvdatas->item(0);
         $csvid = $dom->createElement('id_in_csv', $this->record_key);
         $csvdata->appendChild($csvid);
         $timestamp = date("Y-m-d H:i:s");
         // Add the <CSVRecord> element.
         $csvrecord = $dom->createElement('CSVRecord');
         $now = $dom->createAttribute('timestamp');
         $now->value = $timestamp;
         $csvrecord->appendChild($now);
         $mimetype = $dom->createAttribute('mimetype');
         $mimetype->value = 'application/json';
         $csvrecord->appendChild($mimetype);
         try {
             $metadata_path = $this->settings['FETCHER']['temp_directory'] . DIRECTORY_SEPARATOR . $this->record_key . '.metadata';
             $metadata_contents = file_get_contents($metadata_path);
             $metadata_contents = unserialize($metadata_contents);
             $metadata_contents = json_encode($metadata_contents);
         } catch (Exception $e) {
             $message = "Problem creating <CSVRecord> element for object " . $this->record_key . ":" . $e->getMessage();
             $this->log->addInfo("AddCsvData", array('CSV metadata warning' => $message));
             return '';
         }
         // If the metadata contains the CDATA end delimiter, log and return.
         if (preg_match('/\\]\\]>/', $metadata_contents)) {
             $message = "CSV metadata for object " . $this->record_key . ' contains the CDATA end delimiter ]]>';
             $this->log->addInfo("AddCsvData", array('CSV metadata warning' => $message));
             return '';
         }
         // If we've made it this far, add the metadata to <CcvData> as
         // CDATA and return the modified XML fragment.
         if (strlen($metadata_contents)) {
             $cdata = $dom->createCDATASection($metadata_contents);
             $csvrecord->appendChild($cdata);
             $csvdata->appendChild($csvrecord);
         }
         return $dom->saveXML($dom->documentElement);
     } else {
         // If current fragment is not <extension><CSVData>, return it
         // unmodified.
         return $input;
     }
 }
Ejemplo n.º 23
0
/**
 * 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;
}
Ejemplo n.º 24
0
 /**
  * Implements the reports/create method to create a new report
  *
  * @param string $name The name of the report
  * @return Litmus_Report
  */
 public static function create($name)
 {
     $dom = new DomDocument('1.0', null);
     $root = $dom->createElement('report');
     $dom->appendChild($root);
     $nameElement = $dom->createElement('name', $name);
     $root->appendChild($nameElement);
     $request = $dom->saveXML();
     $rc = Litmus_RESTful_Client::singleton();
     $res = $rc->post('reports.xml', $request);
     $tests = Litmus_Report::load($res);
     return array_pop($tests);
 }
Ejemplo n.º 25
0
 /**
  * @internal
  *
  * @param \DomDocument $dom
  *
  * @return \DOMElement
  */
 public function toXml(\DomDocument $dom)
 {
     $pso = $dom->createElement('PackageServiceOptions');
     if ($this->declaredValue != null) {
         if ($this->declaredValue['CurrencyCode'] == null) {
             $this->declaredValue['CurrencyCode'] = UPS::currencyCode;
         }
         $pso->appendChild($declaredValue = $dom->createElement('InsuredValue'));
         $declaredValue->appendChild($dom->createElement('CurrencyCode', $this->declaredValue['CurrencyCode']));
         $declaredValue->appendChild($dom->createElement('MonetaryValue', $this->declaredValue['MonetaryValue']));
     }
     return $pso;
 }
Ejemplo n.º 26
0
    private function create(DomDocument $document, $id, $value, $number)
    {
        $transUnit = $document->createElement('trans-unit');
        $transUnit->setAttribute('id', $number);
        $source = $document->createElement('source');
        $source->nodeValue = $id;
        $target = $document->createElement('target');
        $target->nodeValue = $value;
        $transUnit->appendChild($source);
        $transUnit->appendChild($target);

        return $transUnit;
    }
Ejemplo n.º 27
0
 public function run()
 {
     $apiDocument = $this->document->createElement("api");
     try {
         $apiDocument = $this->execute($apiDocument);
     } catch (ApiException $ex) {
         $exception = $this->document->createElement("error");
         $exception->setAttribute("message", $ex->getMessage());
         $apiDocument->appendChild($exception);
     }
     $this->document->appendChild($apiDocument);
     return $this->document->saveXml();
 }
Ejemplo n.º 28
0
 /**
  * @internal
  *
  * @param \DomDocument $dom
  *
  * @return \DOMElement
  */
 public function toXml(\DomDocument $dom)
 {
     $shipper = $dom->createElement('Shipper');
     if ($this->getAddress()->getAddressee() != null) {
         $shipper->appendChild($dom->createElement('Name', $this->getAddress()->getAddressee()));
     }
     if ($this->getNumber() != null) {
         $shipper->appendChild($dom->createElement('ShipperNumber', $this->getNumber()));
     }
     if ($this->getAddress() != null) {
         $shipper->appendChild($this->getAddress()->toXml($dom));
     }
     return $shipper;
 }
Ejemplo n.º 29
0
 protected function setUp()
 {
     // Setup DOM
     $this->domDocument = new \DOMDocument('1', 'UTF-8');
     $html = $this->domDocument->createElement('html');
     $this->domAnchor = $this->domDocument->createElement('a', 'fake');
     $this->domAnchor->setAttribute('href', 'http://php-spider.org/contact/');
     $this->domDocument->appendChild($html);
     $html->appendChild($this->domAnchor);
     $this->uri = new DiscoveredUri(new Uri($this->domAnchor->getAttribute('href')));
     // Setup Spider\Resource
     $content = $this->domDocument->saveHTML();
     $this->spiderResource = new Resource($this->uri, new Response(200, [], $content));
 }
Ejemplo n.º 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);
 }