function createTagAttributed($heavyTag, $value = null) { $heavyTag = trim($heavyTag); $name = $heavyTag; $attrs = 0; $attrsPos = strpos($heavyTag, " "); if ($attrsPos) { $name = substr($heavyTag, 0, $attrsPos); $attrs = strstr(trim($heavyTag), " "); } if (!trim($name)) { return false; } $nameSplited = explode(":", $name); if ($nameSplited) { $name = $nameSplited[count($nameSplited) - 1]; } $name = CDataXML::xmlspecialcharsback($name); $node = new CXMLCreator($name); if ($attrs and strlen($attrs)) { $attrsSplit = explode("\"", $attrs); $i = 0; while ($validi = strpos(trim($attrsSplit[$i]), "=")) { $attrsSplit[$i] = trim($attrsSplit[$i]); // attr:ns= $attrName = CDataXML::xmlspecialcharsback(substr($attrsSplit[$i], 0, $validi)); // attrs:ns $attrValue = CDataXML::xmlspecialcharsback($attrsSplit[$i + 1]); $node->setAttribute($attrName, $attrValue); $i = $i + 2; } } if (null !== $value) { $node->setData($value); } return $node; }
function &__parseAttributes($attributeString) { $ret = false; preg_match_all("/(\\S+)\\s*=\\s*([\"'])(.*?)\\2/s" . BX_UTF_PCRE_MODIFIER, $attributeString, $attributeArray); foreach ($attributeArray[0] as $i => $attributePart) { $attributePart = trim($attributePart); if ($attributePart != "" && $attributePart != "/") { $attributeName = $attributeArray[1][$i]; // strip out namespace; nameSpace:Name if ($this->delete_ns) { $colonPos = strpos($attributeName, ":"); if ($colonPos > 0) { // exclusion: xmlns attribute is xmlns:nameSpace if ($colonPos == 5 && substr($attributeName, 0, $colonPos) == 'xmlns') { $attributeName = 'xmlns'; } else { $attributeName = substr($attributeName, $colonPos + 1); } } } $attributeValue = $attributeArray[3][$i]; unset($attrNode); $attrNode = new CDataXMLNode(); $attrNode->name = $attributeName; $attrNode->content = CDataXML::xmlspecialcharsback($attributeValue); $ret[] =& $attrNode; } } return $ret; }
if (strtolower($tls[$i_]->name) != 'tracklist') continue; $tracks = $tls[$i_]->children; for ($i = 0, $l = count($tracks); $i < $l; $i++) { $bIncorrectFormat = false; $track = $tracks[$i]; if (strtolower($track->name) == 'track') { $arTrack = Array('title' => '', 'author' => '', 'location' => '', 'image' => '', 'duration' => ''); for ($j = 0, $n = count($track->children); $j < $n; $j++) { $prop = $track->children[$j]; if (strtolower($prop->name) == 'title') // TODO: Maybe using xmlspecialcharsback - is bogus $arTrack['title'] = $objXML->xmlspecialcharsback($prop->content); if (strtolower($prop->name) == 'creator') $arTrack['author'] = $objXML->xmlspecialcharsback($prop->content); if (strtolower($prop->name) == 'location') $arTrack['location'] = $objXML->xmlspecialcharsback($prop->content); if (strtolower($prop->name) == 'image') $arTrack['image'] = $objXML->xmlspecialcharsback($prop->content); if (strtolower($prop->name) == 'duration') $arTrack['duration'] = $objXML->xmlspecialcharsback($prop->content); } $arTracks[] = $arTrack; } } break; } }