當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DOMDocument::createEntityReference方法代碼示例

本文整理匯總了PHP中DOMDocument::createEntityReference方法的典型用法代碼示例。如果您正苦於以下問題:PHP DOMDocument::createEntityReference方法的具體用法?PHP DOMDocument::createEntityReference怎麽用?PHP DOMDocument::createEntityReference使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在DOMDocument的用法示例。


在下文中一共展示了DOMDocument::createEntityReference方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: xsl_splitContrib

function xsl_splitContrib($m)
{
    $SEP = ',';
    $dom = new DOMDocument();
    $root = $dom->createElement('contrib-group');
    $txt = $m[0]->textContent;
    // contribs não tem tags, ok txt!
    //foreach ($m[0]->childNodes as $node) $txt .= $node->nodeValue;
    $lst = explode($SEP, $txt);
    //for($i=count($lst)-1; $i+1; $i--) {
    $ni = count($lst) - 1;
    for ($i = 0; $i <= $ni; $i++) {
        $name = trim($lst[$i]);
        $isCorresp = 0;
        $name = preg_replace('/\\*$/', '', $name, 1, $isCorresp);
        $node = $dom->createElement('contrib');
        // ,$name
        $node->setAttribute('contrib-type', 'author');
        if ($isCorresp) {
            $node->setAttribute('corresp', 'yes');
        }
        if (preg_match('/^(.+?)\\s+(.+?)$/', $name, $m)) {
            $surname = str_replace('-', '‑', $m[1]);
            //'&#8209;' copiado como  "―"
            $given = str_replace('-', '‑', $m[2]);
            $node->appendChild($dom->createElement('surname', $surname));
            //$node->appendChild( $dom->createTextNode(' ') ); // cuidado é NBSP dá pau! enquanto createTextNode('♣') funciona!
            // ver meu comentario em http://stackoverflow.com/a/8867502/287948 (mas resolvido por hora)
            $node->appendChild($dom->createEntityReference('nbsp'));
            $node->appendChild($dom->createElement('given-names', $given));
            // initials
        } else {
            $node->appendChild($dom->createElement('surname', $name));
        }
        $root->appendChild($node);
        if ($i < $ni) {
            // not last
            $root->appendChild($dom->createTextNode("{$SEP} "));
        }
        // menos no last!
    }
    return $root;
}
開發者ID:solangefpaulino,項目名稱:SBPqO-2015,代碼行數:43,代碼來源:lib.php

示例2: DOMDocument

<?php

$dom = new DOMDocument('1.0');
$ref = $dom->createEntityReference('nbsp');
$dom->appendChild($ref);
echo $dom->saveXML();
開發者ID:badlamer,項目名稱:hhvm,代碼行數:6,代碼來源:DOMDocument_createEntityReference_basic.php

示例3: addStatic

 /**
  *   Adds a simpara and a static entity to an existing method declaration.
  *
  *   Hackish but working.
  *
  *   @param  DOMDocument $doc  The DOMDocument object.
  *   @param  DOMNode     $desc The DOMNode for the method description.
  *   @return boolean true if the method was updated.
  */
 function addStatic(DOMDocument $doc, DOMNode $desc)
 {
     // Check to see if the static entity has already been added.
     if ($desc->hasChildNodes()) {
         /**
          *   BAD HACK: This will not work anymore if the
          *   entity changes.
          */
         // The DOMDocument translates the entities on loading.
         $staticText = 'This method must be called statically.';
         // Get simparas.
         $list = $desc->getElementsByTagName('simpara');
         for ($i = 0; $i < $list->length; ++$i) {
             $node = $list->item($i);
             if ($node->hasChildNodes()) {
                 // Check for the static text.
                 $child = $node->firstChild;
                 do {
                     if ($child instanceof DOMText && trim($child->wholeText) == $staticText) {
                         return false;
                     }
                 } while ($child = $child->nextSibling);
             }
         }
     }
     $simpara = $doc->createElement('simpara');
     $simpara->appendChild($doc->createTextNode("\n     "));
     $simpara->appendChild($doc->createEntityReference('static'));
     $simpara->appendChild($doc->createTextNode("\n    "));
     $desc->appendChild($doc->createTextNode(' '));
     $desc->appendChild($simpara);
     $desc->appendChild($doc->createTextNode("\n   "));
     return true;
 }
開發者ID:phpsource,項目名稱:doc-gtk,代碼行數:43,代碼來源:updateMethods.php


注:本文中的DOMDocument::createEntityReference方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。