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


PHP CDataXML::__parseAttributes方法代码示例

本文整理汇总了PHP中CDataXML::__parseAttributes方法的典型用法代码示例。如果您正苦于以下问题:PHP CDataXML::__parseAttributes方法的具体用法?PHP CDataXML::__parseAttributes怎么用?PHP CDataXML::__parseAttributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CDataXML的用法示例。


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

示例1: __parse


//.........这里部分代码省略.........
             //because cdata may contain > and < chars
             //it is special processing needed
             $cdata = "";
             for ($i = 0, $c = count($arTag); $i < $c; $i++) {
                 $cdata .= $arTag[$i] . ">";
                 if (substr($cdata, -3) == "]]>") {
                     $tagContent = $arTag[$i + 1];
                     break;
                 }
             }
             if (substr($cdata, -3) != "]]>") {
                 $cdata = substr($cdata, 0, -1) . "<";
                 do {
                     $tok = strtok(">");
                     //unfortunatly strtok eats > followed by >
                     $cdata .= $tok . ">";
                     //util end of string or end of cdata found
                 } while ($tok !== false && substr($tok, -2) != "]]");
                 //$tagName = substr($tagName, 0, -1);
             }
             $cdataSection = substr($cdata, 8, -3);
             // new CDATA node
             $subNode = new CDataXMLNode();
             $subNode->name = "cdata-section";
             $subNode->content = $cdataSection;
             $currentNode->children[] = $subNode;
             $currentNode->content .= $subNode->content;
             // convert special chars
             if (!$this->TrimWhiteSpace || trim($tagContent) != "") {
                 $currentNode->content = str_replace($search, $replace, $tagContent);
             }
         } else {
             // normal start tag
             $firstSpaceEnd = strpos($tagName, " ");
             $firstNewlineEnd = strpos($tagName, "\n");
             if ($firstNewlineEnd != false) {
                 if ($firstSpaceEnd != false) {
                     $tagNameEnd = min($firstSpaceEnd, $firstNewlineEnd);
                 } else {
                     $tagNameEnd = $firstNewlineEnd;
                 }
             } else {
                 if ($firstSpaceEnd != false) {
                     $tagNameEnd = $firstSpaceEnd;
                 } else {
                     $tagNameEnd = 0;
                 }
             }
             if ($tagNameEnd > 0) {
                 $justName = substr($tagName, 0, $tagNameEnd);
             } else {
                 $justName = $tagName;
             }
             // strip out namespace; nameSpace:Name
             if ($this->delete_ns) {
                 $colonPos = strpos($justName, ":");
                 if ($colonPos > 0) {
                     $justName = substr($justName, $colonPos + 1);
                 }
             }
             // remove trailing / from the name if exists
             $justName = rtrim($justName, "/");
             $subNode = new CDataXMLNode();
             $subNode->_parent = $currentNode;
             $subNode->name = $justName;
             // find attributes
             if ($tagNameEnd > 0) {
                 $attributePart = substr($tagName, $tagNameEnd);
                 // attributes
                 unset($attr);
                 $attr = CDataXML::__parseAttributes($attributePart);
                 if ($attr != false) {
                     $subNode->attributes = $attr;
                 }
             }
             // convert special chars
             if (!$this->TrimWhiteSpace || trim($tagContent) != "") {
                 $subNode->content = str_replace($search, $replace, $tagContent);
             }
             $currentNode->children[] = $subNode;
             if (substr($tagName, -1) != "/") {
                 $currentNode = $subNode;
             }
         }
         //Next iteration
         $tok = strtok("<");
         $arTag = explode(">", $tok);
         //There was whitespace before < just after CDATA section, so make another try
         if (count($arTag) < 2 && strncmp($tagName, "![CDATA[", 8) === 0) {
             $currentNode->content .= $arTag[0];
             // convert special chars
             if (!$this->TrimWhiteSpace || trim($tagContent) != "") {
                 $currentNode->content = str_replace($search, $replace, $tagContent);
             }
             $tok = strtok("<");
             $arTag = explode(">", $tok);
         }
     }
     return $oXMLDocument;
 }
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:101,代码来源:xml.php


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