本文整理汇总了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;
}