コード例 #1
0
 /**
  * Add a child element; this corrects CDATA issues
  *
  * @throws RuntimeException
  */
 public function addChild($name, $value = NULL, $namespace = NULL)
 {
     if ($this->isCData($value) || $this->getConfig('autoCData', FALSE) && $this->wrapCData($value)) {
         // Stash a CDATA value for later...
         $valueAsCData = $value;
         $value = NULL;
     } elseif ($this->getConfig('autoEntities', FALSE)) {
         $this->xmlChars($value);
     }
     $child = parent::addChild($name, $value, $namespace);
     // switch (func_num_args()) {
     //   case 1:
     //     $child = parent::addChild($name);
     //     break;
     //   case 2:
     //     $child = parent::addChild($name, $value);
     //     break;
     //   case 3:
     //     $child = parent::addChild($name, $value, $namespace);
     //     break;
     // }
     if (isset($valueAsCData)) {
         $node = dom_import_simplexml($child);
         $no = $node->ownerDocument;
         $value = self::stripCData($valueAsCData);
         $node->appendChild($no->createCDATASection($value));
     }
     return $child;
 }
コード例 #2
0
ファイル: WxpayRequest.php プロジェクト: ccq18/EduSoho
 private function toXml($array, $xml = false)
 {
     $simxml = new simpleXMLElement('<!--?xml version="1.0" encoding="utf-8"?--><root></root>');
     foreach ($array as $k => $v) {
         $simxml->addChild($k, $v);
     }
     return $simxml->saveXML();
 }
コード例 #3
0
ファイル: Connector.php プロジェクト: jlehmus/NDL-VuFind2
 /**
  * Convert array of X-Server call parameters to XML
  *
  * @param simpleXMLElement $node  The target node
  * @param array            $array Array to convert
  *
  * @return void
  */
 protected function paramsToXml($node, $array)
 {
     foreach ($array as $key => $value) {
         if (is_array($value)) {
             $path = explode('/', $key, 2);
             if (isset($path[1])) {
                 foreach ($value as $single) {
                     $child = $node->addChild($path[0]);
                     $child->addChild($path[1], $single);
                 }
             } else {
                 $child = $node->addChild($path[0]);
                 foreach ($value as $vkey => $single) {
                     $child->addChild($vkey, $single);
                 }
             }
         } else {
             $node->addChild($key, $value);
         }
     }
 }
コード例 #4
0
ファイル: edit.php プロジェクト: houzanme1/fabulous
            if ($_POST['function_type'] == "Delete") {
                // print_r($GLOBALS);
                $deleteDataField = $_POST['dataFieldtag'];
                foreach ($fields as $key => $val) {
                    $xml_MARC = get_Datastream($val, $marcID);
                    $xml_output_dc = get_Datastream($val, $dcID);
                    $handle = retrieveHandle($xml_output_dc, $dictionary['HandleNamespace']);
                    $marcxml = deleteNode($xml_MARC, $deleteDataField);
                    $agent = new Agent();
                    $dc_temp = $agent->transform2("./stylesheets/dc.xslt", $marcxml);
                    //append identifiers information into DC i.e Handles (namespace:port and pid extracted from Val) and Pid = val
                    $xmlDC = new simpleXMLElement($dc_temp);
                    $namespace = $xmlDC->getNamespaces(true);
                    $split = explode(":", $val);
                    // $handle=$dictionary['HandleNamespace'].$split[1];
                    $xmlDC->addChild('dc:identifier', $val, $namespace['dc']);
                    $xmlDC->addChild('dc:identifier', $handle, $namespace['dc']);
                    $dc = $xmlDC->saveXML();
                    $marc = $marcxml->saveXML();
                    $myFile1 = base64_encode(trim($marc));
                    $myFile2 = base64_encode(trim($dc));
                    $agent->callModifyDatastreamByValue($val, $marcID, 'I', $marcLabel, $marc);
                    $agent->callModifyDatastreamByValue($val, $dcID, 'A', $dcLabel, $dc);
                }
                $htmlFinal .= "<h1> Deleted all Occurances of </h1>Datafield  '" . $deleteDataField . "' <h1> for Objects</h1>";
            } else {
                $htmlFinal .= "Please select a functionality before proceeding !";
            }
        }
    }
} else {
コード例 #5
0
ファイル: unleashedAPI.php プロジェクト: Qualitair/ecommerce
function testPostNewSalesInvoiceXml()
{
    echo "Starting test: testPostNewSalesInvoiceXml" . "<br />";
    echo "-------------------------------------------------------------------------------------<br />";
    echo "POST new sales invoice in XML format:" . "<br />";
    $guid = NewGuid();
    echo "New GUID = {$guid}";
    echo "<br />";
    $date = date('Y-m-d');
    $taxRate = 0.15;
    $taxCode = "G.S.T.";
    // creating an xml object in PHP:
    $invoice = new simpleXMLElement('<SalesInvoice />');
    // set all the properties of the sales invoice
    // use simple xml, not stdClass
    $invoice->Guid = "{$guid}";
    $invoice->OrderNumber = substr($guid, 0, 15);
    $invoice->OrderDate = $date;
    $invoice->RequiredDate = $date;
    $invoice->OrderStatus = "Parked";
    $invoice->Customer->CustomerCode = "ACE001";
    $invoice->Currency->CurrencyCode = "NZD";
    $invoice->Warehouse->WarehouseCode = "W1";
    $invoice->Tax->TaxCode = $taxCode;
    $lines = $invoice->addChild('SalesOrderLines');
    addSalesInvoiceLineXml($lines, 1, 'ANIMAL', 5, 10, $taxRate);
    addSalesInvoiceLineXml($lines, 2, 'BISCUIT', 10, 2, $taxRate);
    addSalesInvoiceLineXml($lines, 3, 'CANDY', 1, 25, $taxRate);
    $invoice->SubTotal = 95.0;
    $invoice->TaxTotal = 14.25;
    $invoice->Total = 109.25;
    echo "Input data:" . "<br />";
    echo htmlentities($invoice->asXML());
    echo "<br />";
    echo "Input id:" . "<br />";
    echo $invoice->Guid;
    echo "<br />";
    echo "<br />";
    $xmlPost = postSalesInvoice($invoice, "xml", $invoice->Guid);
    echo "Output data:" . "<br />";
    echo htmlentities($xmlPost->asXML());
}
コード例 #6
0
ファイル: bug44478.php プロジェクト: badlamer/hhvm
<?php

$xml_element = new simpleXMLElement('<root></root>');
$xml_element->node1 = 'a &#38; b';
print $xml_element->node1 . "\n";
$xml_element->node1 = 'a &#38; b';
print $xml_element->node1 . "\n";
$xml_element->addChild('node2', 'a &#38; b');
print $xml_element->node2 . "\n";
$xml_element->node2 = 'a & b';
print $xml_element->node2 . "\n";
print $xml_element->asXML();
?>
===DONE===