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


PHP DomDocument类代码示例

本文整理汇总了PHP中DomDocument的典型用法代码示例。如果您正苦于以下问题:PHP DomDocument类的具体用法?PHP DomDocument怎么用?PHP DomDocument使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: __doRequest

 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);
 }
开发者ID:vallejos,项目名称:samples,代码行数:29,代码来源:ContentGatewayBilling.php

示例2: getXMLSing

	function getXMLSing($xmlHon,$priv_key){
		//Carga Certificado
		$xml = new DomDocument();
		$xml->loadXML($xmlHon);
		//Carga prosedimiento de proceso de cadena original
		$xsl = new DomDocument;
		$xsl->load("ostring.xsl");
		$proc = new xsltprocessor();
		$proc->importStyleSheet($xsl);
		$original =$proc->transformToXML($xml);
		//firma la cadena original
		
		//$fp = $cert[0]['certificates']['key'];
		//$priv_key = $f['key'];
		//die($f['key']);
		//fclose($fp);
		$pkeyid = openssl_get_privatekey($priv_key);
		openssl_sign($original, $signature, $pkeyid,OPENSSL_ALGO_MD5);
		openssl_free_key($pkeyid);
		//coloca el sello en xml
		$esqueletonew=$xmlHon;
		$esqueletonew=str_replace("#1#",base64_encode($signature),$esqueletonew);
		$xmlReturn[1]=$esqueletonew;
		$xmlReturn[2]=$original;
		$xmlReturn[3]=base64_encode($signature);
		return $xmlReturn;
	}
开发者ID:sigmadesarrollo,项目名称:logisoft,代码行数:27,代码来源:ActualizarFacturas.php

示例3: run

 public function run($str = NULL)
 {
     if ($str == NULL) {
         return $this;
     }
     $document = jqm_use($this->node->_parentElement);
     $dom = $document->_DOM;
     if ($dom->doctype) {
         $dom->removeChild($dom->doctype);
     }
     $find = $this->node->getPathById($dom);
     if (!$find) {
         $find = $this->node->_path;
     }
     $xpath = new DomXpath($dom);
     $find = $xpath->query($find);
     if ($find->length > 0) {
         $child = new DomDocument();
         $child->loadHtml($str);
         if ($child->doctype) {
             $child->removeChild($child->doctype);
         }
         $child->normalize();
         $frag = $dom->importNode($child->firstChild->firstChild->firstChild, true);
         $save = $find->item(0)->parentNode->insertBefore($frag, $find->item(0));
         $this->node->_path = $save->nextSibling->getNodePath();
         $document->_DOM = $dom;
     }
     return $this;
 }
开发者ID:Webictbyleo,项目名称:JqueryPhp,代码行数:30,代码来源:before.php

示例4: buildModel

 public function buildModel($model)
 {
     try {
         $dom = new DomDocument();
         $dom->Load($this->loadModel($model));
         $rooms_base = $dom->getElementsByTagName("roomdata");
         foreach ($rooms_base as $rooms_bases) {
             $roomtypes = $rooms_bases->getElementsByTagName("roomtype")->item(0)->nodeValue;
             $caption = $rooms_bases->getElementsByTagName("caption")->item(0)->nodeValue;
             $model_name = $rooms_bases->getElementsByTagName("model_name")->item(0)->nodeValue;
             $description = $rooms_bases->getElementsByTagName("description")->item(0)->nodeValue;
             if ($this->createRooms($roomtypes, $caption, $username, $description, $model_name)) {
                 echo 'Done rooms<br/>';
             }
         }
         foreach ($dom->getElementsByTagName("roomitem") as $room_items) {
             foreach ($room_items->getElementsByTagName("item") as $item) {
                 $base_item = $item->getElementsByTagName("base_item")->item(0)->nodeValue;
                 $x = $item->getElementsByTagName("x")->item(0)->nodeValue;
                 $y = $item->getElementsByTagName("y")->item(0)->nodeValue;
                 $z = $item->getElementsByTagName("z")->item(0)->nodeValue;
                 $rot = $item->getElementsByTagName("rot")->item(0)->nodeValue;
                 $coord = array('x' => $x, 'y' => $y, 'z' => $z);
                 if ($this->addItemsToRooms($user_id, null, $base_item, $coord, $rot)) {
                     echo 'Done ' . $base_item . '<br/>';
                 }
             }
         }
     } catch (Exception $e) {
         echo $e->getMessage();
     }
 }
开发者ID:habb0,项目名称:HabboPHP,代码行数:32,代码来源:rooms.class.php

示例5: getImportantActs

function getImportantActs($xml_url, $xsl_filename, $n_nodes)
{
    try {
        // read the xml from url
        $xmldoc = new DomDocument();
        $xmldoc->load($xml_url);
        // read xslt file
        $xsldoc = new DomDocument();
        $xsldoc->load($xsl_filename);
        $xsl = new XSLTProcessor();
        $xsl->importStyleSheet($xsldoc);
        // trasforma XML secondo l'XSLT ed estrae il contenuto del div
        $transformed_xml = new SimpleXMLElement($xsl->transformToXML($xmldoc));
        $nodes = $transformed_xml->children();
        // write values to screen
        $cnt = 0;
        foreach ($nodes as $node) {
            $cnt++;
            $atto = OppAttoPeer::retrieveByPK($node['atto_id']);
            printf("\t%d. %s => %f\n", $cnt, $atto->getTitoloCompleto(), $node['totale']);
            if ($cnt >= $n_nodes) {
                break;
            }
        }
    } catch (Exception $e) {
        printf("Errore durante la scrittura del file: %s\n", $e->getMessage());
    }
}
开发者ID:valerio-bozzolan,项目名称:openparlamento,代码行数:28,代码来源:anno0Tasks.php

示例6: parse_session_status_XML

function parse_session_status_XML($xml_)
{
    if (!$xml_ || strlen($xml_) == 0) {
        return false;
    }
    $dom = new DomDocument('1.0', 'utf-8');
    $buf = @$dom->loadXML($xml_);
    if (!$buf) {
        return false;
    }
    if (!$dom->hasChildNodes()) {
        return false;
    }
    $node = $dom->getElementsByTagname('session')->item(0);
    if (is_null($node)) {
        return false;
    }
    if (!$node->hasAttribute('id')) {
        return false;
    }
    if (!$node->hasAttribute('status')) {
        return false;
    }
    $ret = array('id' => $node->getAttribute('id'), 'server' => $_SERVER['REMOTE_ADDR'], 'status' => $node->getAttribute('status'), 'reason' => NULL, 'role' => NULL);
    if ($node->hasAttribute('reason')) {
        $ret['reason'] = $node->getAttribute('reason');
    }
    if ($node->hasAttribute('role')) {
        $ret['role'] = $node->getAttribute('role');
    }
    return $ret;
}
开发者ID:bloveing,项目名称:openulteo,代码行数:32,代码来源:session_status.php

示例7: process

function process($xml)
{
    /* load xsl*/
    $filter = true;
    //remember edit on js file
    if ($filter) {
        $xmlSession = $_SESSION["process"];
        //$xmlSession = simplexml_load_string($xmlSession);
        $xml = new DOMDocument();
        $xml->loadXML($xmlSession);
        $fileXSLPath = $GLOBALS["fileXSL_process"];
        $xslDoc = new DomDocument();
        $xslDoc->load($fileXSLPath);
        //combine xsl into xml
        $proc = new XSLTProcessor();
        $proc->importStyleSheet($xslDoc);
        $xmlTrans = $proc->transformToXML($xml);
        $xmlTrans = simplexml_load_string($xmlTrans);
        $resultXml = $xmlTrans->saveXML();
        processFile($xml);
        echo $resultXml;
    } else {
        echo $xml->saveXML();
        //way 2
        //echo $xml->asXML();
    }
}
开发者ID:haiha262,项目名称:WAD,代码行数:27,代码来源:processing.php

示例8: main

 /**
  * Applies action
  *
  * @return  boolean success
  */
 protected function main()
 {
     $flow = Nexista_Flow::Singleton('Nexista_Flow');
     $file_path = Nexista_Path::parseInlineFlow($this->params['xsl']);
     $xslfile = NX_PATH_APPS . $file_path;
     if (!is_file($xslfile)) {
         Nexista_Error::init('XSL Action - file unavailable: ' . $xslfile, NX_ERROR_FATAL);
     }
     $xsl = new DomDocument('1.0', 'UTF-8');
     $xsl->substituteEntities = false;
     $xsl->resolveExternals = false;
     $xslfilecontents .= file_get_contents($xslfile);
     $xsl->loadXML($xslfilecontents);
     $xsl->documentURI = $xslfile;
     $use_xslt_cache = "yes";
     if ($use_xslt_cache != "yes" || !class_exists('xsltCache')) {
         $xslHandler = new XsltProcessor();
     } else {
         $xslHandler = new xsltCache();
     }
     $xslHandler->importStyleSheet($xsl);
     $my_output = $xslHandler->transformToXML($flow->flowDocument);
     if ($my_output === false) {
         Nexista_Error::init('XSL Action - Error processing XSL file: ' . $xslfile, NX_ERROR_FATAL);
         return false;
     }
     $new_node = $this->params['new_node'];
     Nexista_Flow::add($new_node, $my_output);
     return true;
 }
开发者ID:savonix,项目名称:nexista,代码行数:35,代码来源:xsl.action.php

示例9: hal_parse

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;
}
开发者ID:RBoisselet,项目名称:spip_webpage_from_hal,代码行数:25,代码来源:webpage_from_hal_fonctions.php

示例10: exec

 /**
  * 
  * @param string $html
  */
 public function exec($html)
 {
     mb_language('Japanese');
     // 1.プリプロセス
     // scriptテキスト削除
     // script内に文字列リテラルの閉じタグがあるとDomDocumentがscriptのソースを#text扱いしてしまうので
     // script内の文字を削除する
     // 正規表現で削除しようとするとSegmentation faultが発生する(StackOverFlow?)ので
     // simple_html_domでscript内文字列を削除
     // MAX_FILE_SIZEの制限にひっかかったので、ソースを編集してデフォルトの3倍に変更している
     $simpleHtml = str_get_html($html);
     foreach ($simpleHtml->find('script') as $script) {
         $script->innertext = '';
     }
     $html = $simpleHtml->outertext;
     // トリム
     //		$html = preg_replace('/(\s| )+/mi', ' ', $html);
     // 2. dom生成
     $doc = new DomDocument("1.0", "utf-8");
     @$doc->loadHTML(mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8'));
     $node = $doc->getElementsByTagName('body')->item(0);
     $this->preProcessedInput = $node->textContent;
     // 3.プロパティを初期化
     $this->domXPath = new DomXPath($doc);
     $this->title = @$doc->getElementsByTagName('title')->item(0)->textContent;
     $text = $this->scan($node);
     $this->textAll = $text;
     $this->domCountAll = $this->domCount;
     $this->pancutuationCountAll = $this->calcKutenScore($text) + $this->calcTotenScore($text);
     $this->textLengthAll = mb_strlen($text);
     $this->highScore = -1000000;
     $this->extracedNode = null;
     // 4.実行
     $this->extract($node);
 }
开发者ID:gammodoking,项目名称:kindle.server,代码行数:39,代码来源:ContentExtractor.php

示例11: serializePortableProperties

 /**
  * 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;
 }
开发者ID:oat-sa,项目名称:extension-tao-itemqti,代码行数:40,代码来源:PortableElementTrait.php

示例12: response

 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();
 }
开发者ID:nattomi,项目名称:ReportGenerator,代码行数:25,代码来源:response.php

示例13: createCollection

 function createCollection($theUser, $pid, $soapClient)
 {
     $dom = new DomDocument("1.0", "UTF-8");
     $dom->formatOutput = true;
     $rootElement = $dom->createElement("foxml:digitalObject");
     $rootElement->setAttribute('PID', "{$pid}");
     $rootElement->setAttribute('xmlns:foxml', "info:fedora/fedora-system:def/foxml#");
     $rootElement->setAttribute('xmlns:xsi', "http://www.w3.org/2001/XMLSchema-instance");
     $rootElement->setAttribute('xsi:schemaLocation', "info:fedora/fedora-system:def/foxml# http://www.fedora.info/definitions/1/0/foxml1-0.xsd");
     $dom->appendChild($rootElement);
     //create standard fedora stuff
     $this->createStandardFedoraStuff($theUser, $dom, $rootElement);
     //create dublin core
     $this->createDCStream($theUser, $dom, $rootElement);
     $value = $this->createPolicyStream($theUser, $dom, $rootElement);
     if (!$value) {
         return false;
         //error should already be logged.
     }
     $this->createCollectionPolicyStream($theUser, $dom, $rootElement);
     try {
         $params = array('objectXML' => $dom->saveXML(), 'format' => "foxml1.0", 'logMessage' => "Fedora Object Ingested");
         $object = $soapClient->__soapCall('ingest', array($params));
     } catch (exception $e) {
         drupal_set_message(t('Error Ingesting Personal Collection Object! ') . $e->getMessage(), 'error');
         return false;
     }
     return true;
 }
开发者ID:ratzeni,项目名称:islandora,代码行数:29,代码来源:PersonalCollectionClass.php

示例14: getForm

 public function getForm($formId, $params, $headers)
 {
     /** @var DOMElement $form */
     $dom = new DomDocument();
     libxml_use_internal_errors(true);
     $dom->loadHTML($this->response());
     $xpath = new DOMXpath($dom);
     $form = $xpath->query("//form[@id='{$formId}']")->item(0);
     $elements = $xpath->query('//input');
     $form_params = [];
     $allowedTypes = ["hidden", "text", "password"];
     foreach ($elements as $element) {
         /** @var DOMElement $element */
         $type = $element->getAttribute("type");
         if (in_array($type, $allowedTypes)) {
             $name = $element->getAttribute("name");
             $value = $element->getAttribute("value");
             $form_params[$name] = $value;
         }
     }
     $headers = array_merge(["Referer" => $this->baseUri], $headers);
     $url = Uri::resolve(new Uri($this->baseUri), $form->getAttribute("action"))->__toString();
     $method = strtoupper($form->getAttribute("method"));
     return ["method" => $method, "url" => $url, "headers" => $headers, "params" => array_merge($form_params, $params)];
 }
开发者ID:ifgroup,项目名称:browser,代码行数:25,代码来源:Browser.php

示例15: call_success

 public function call_success()
 {
     global $USER, $COURSE, $CFG;
     if (empty($this->_xmlresponse)) {
         if (is_siteadmin($USER->id)) {
             notice(get_string('adminemptyxml', 'adobeconnect'), $CFG->wwwroot . '/admin/settings.php?section=modsettingadobeconnect');
         } else {
             notice(get_string('emptyxml', 'adobeconnect'), '', $COURSE);
         }
     }
     $dom = new DomDocument();
     $dom->loadXML($this->_xmlresponse);
     $domnodelist = $dom->getElementsByTagName('status');
     if ($domnodelist->item(0)->hasAttributes()) {
         $domnode = $domnodelist->item(0)->attributes->getNamedItem('code');
         if (!is_null($domnode)) {
             if (0 == strcmp('ok', $domnode->nodeValue)) {
                 return true;
             } else {
                 return false;
             }
         } else {
             return false;
         }
     } else {
         return false;
     }
 }
开发者ID:nagyistoce,项目名称:moodle-Teach-Pilot,代码行数:28,代码来源:connect_class_dom.php


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