本文整理汇总了PHP中DOMElement::getElementsByTagNameNS方法的典型用法代码示例。如果您正苦于以下问题:PHP DOMElement::getElementsByTagNameNS方法的具体用法?PHP DOMElement::getElementsByTagNameNS怎么用?PHP DOMElement::getElementsByTagNameNS使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DOMElement
的用法示例。
在下文中一共展示了DOMElement::getElementsByTagNameNS方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setNamespace
public function setNamespace($namespace)
{
$node = $this->contextNode->getElementsByTagNameNS('http://schema.phpunit.de/coverage/1.0', 'namespace')->item(0);
if (!$node) {
$node = $this->contextNode->appendChild($this->contextNode->ownerDocument->createElementNS('http://schema.phpunit.de/coverage/1.0', 'namespace'));
}
$node->setAttribute('name', $namespace);
}
示例2: getLineCoverage
public function getLineCoverage($line)
{
$coverage = $this->contextNode->getElementsByTagNameNS('http://schema.phpunit.de/coverage/1.0', 'coverage')->item(0);
if (!$coverage) {
$coverage = $this->contextNode->appendChild($this->dom->createElementNS('http://schema.phpunit.de/coverage/1.0', 'coverage'));
}
$lineNode = $coverage->appendChild($this->dom->createElementNS('http://schema.phpunit.de/coverage/1.0', 'line'));
return new PHP_CodeCoverage_Report_XML_File_Coverage($lineNode, $line);
}
示例3: getHrefs
public function getHrefs($locatorLabel)
{
if (is_null($this->locations)) {
$locations = array();
$results = $this->element->getElementsByTagNameNS('http://www.xbrl.org/2003/linkbase', 'loc');
/** @var $result \DOMElement */
foreach ($results as $result) {
$label = $result->getAttributeNS('http://www.w3.org/1999/xlink', 'label');
$locations[$label] = empty($locations[$label]) ? array() : $locations[$label];
$locations[$label][] = $this->linkBase->getConceptId($result->getAttributeNS('http://www.w3.org/1999/xlink', 'href'));
}
$this->locations = $locations;
}
return $this->locations[$locatorLabel];
}
示例4: assertPropertyExists
protected function assertPropertyExists($exptectedNs, $expectedName, array $expectedProperties, DOMElement $actualParent)
{
$props = $actualParent->getElementsByTagNameNS($exptectedNs, $expectedName);
$this->assertEquals(1, $props->length);
$prop = $props->item(0);
foreach ($expectedProperties as $propDef) {
$this->assertTrue($prop->hasAttributeNs($propDef[0], $propDef[1]));
}
}
示例5: insertImageData
/**
* Inserts $imageData as a child into $imageObject.
*
* Detects if $imageObject contains <office:binary-data/>. If this is the case,
* this element is replaced with the given $imageData. Otherwise,
* $imageData is added as a new child.
*
* @param DOMElement $imageObject
* @param DOMElement $imageData
*/
protected function insertImageData($imageObject, $imageData)
{
$binaryDataElems = $imageObject->getElementsByTagNameNS(ezcDocumentOdt::NS_ODT_OFFICE, 'binary-data');
if ($binaryDataElems->length === 1) {
$imageObject->replaceChild($imageData, $binaryDataElems->item(0));
} else {
$imageObject->appendChild($imageData);
}
}
示例6: unserialize
public static function unserialize(\DOMElement $dom)
{
$principals = array();
$xhrefs = $dom->getElementsByTagNameNS('urn:DAV', 'href');
for ($ii = 0; $ii < $xhrefs->length; $ii++) {
$principals[] = $xhrefs->item($ii)->textContent;
}
return new self($principals);
}
示例7: _process
protected function _process(DOMElement $root)
{
foreach ($root->getElementsByTagNameNS($this->_acNS, '*') as $element) {
/* @var $element Ajde_Template_Parser_Xhtml_Element */
if ($element->inACNameSpace()) {
$element->processComponent($this);
} elseif ($element->inAVNameSpace()) {
$element->processVariable($this);
}
}
return $root;
}
示例8: unserialize
/**
* Unserializes the {DAV:}acl xml element.
*
* @param \DOMElement $dom
* @param array $propertyMap
* @return Acl
*/
static function unserialize(\DOMElement $dom, array $propertyMap)
{
$privileges = [];
$xaces = $dom->getElementsByTagNameNS('urn:DAV', 'ace');
for ($ii = 0; $ii < $xaces->length; $ii++) {
$xace = $xaces->item($ii);
$principal = $xace->getElementsByTagNameNS('urn:DAV', 'principal');
if ($principal->length !== 1) {
throw new DAV\Exception\BadRequest('Each {DAV:}ace element must have one {DAV:}principal element');
}
$principal = Principal::unserialize($principal->item(0), $propertyMap);
switch ($principal->getType()) {
case Principal::HREF:
$principal = $principal->getHref();
break;
case Principal::AUTHENTICATED:
$principal = '{DAV:}authenticated';
break;
case Principal::UNAUTHENTICATED:
$principal = '{DAV:}unauthenticated';
break;
case Principal::ALL:
$principal = '{DAV:}all';
break;
}
$protected = false;
if ($xace->getElementsByTagNameNS('urn:DAV', 'protected')->length > 0) {
$protected = true;
}
$grants = $xace->getElementsByTagNameNS('urn:DAV', 'grant');
if ($grants->length < 1) {
throw new DAV\Exception\NotImplemented('Every {DAV:}ace element must have a {DAV:}grant element. {DAV:}deny is not yet supported');
}
$grant = $grants->item(0);
$xprivs = $grant->getElementsByTagNameNS('urn:DAV', 'privilege');
for ($jj = 0; $jj < $xprivs->length; $jj++) {
$xpriv = $xprivs->item($jj);
$privilegeName = null;
for ($kk = 0; $kk < $xpriv->childNodes->length; $kk++) {
$childNode = $xpriv->childNodes->item($kk);
if ($t = DAV\XMLUtil::toClarkNotation($childNode)) {
$privilegeName = $t;
break;
}
}
if (is_null($privilegeName)) {
throw new DAV\Exception\BadRequest('{DAV:}privilege elements must have a privilege element contained within them.');
}
$privileges[] = ['principal' => $principal, 'protected' => $protected, 'privilege' => $privilegeName];
}
}
return new self($privileges);
}
示例9: getElement
function getElement(DOMElement $parent, $tagname, $ns = NULL)
{
if ($ns !== NULL) {
$el = $parent->getElementsByTagNameNS($ns, preg_replace('/^.*:/', '', $tagname))->item(0);
} else {
$el = $parent->getElementsByTagName($tagname)->item(0);
}
if (!$el) {
$el = $parent->ownerDocument->createElementNS($ns, $tagname);
$parent->appendChild($el);
newline($parent);
}
return $el;
}
示例10: filterElement
/**
* Filter a single element.
*
* @param DOMElement $element
* @return void
*/
public function filterElement(DOMElement $element)
{
$element->setProperty('type', 'footnote');
$citations = $element->getElementsByTagNameNS(ezcDocumentOdt::NS_ODT_TEXT, 'note-citation');
// Should be only 1, foreach to remove all
foreach ($citations as $cite) {
$attrs = $element->getProperty('attributes');
if ($attrs === false) {
$attrs = array();
}
$attrs['label'] = $cite->nodeValue;
$element->setProperty('attributes', $attrs);
$element->removeChild($cite);
}
}
示例11: unserialize
/**
* Unserializes the {DAV:}current-user-privilege-set element.
*
* @param DOMElement $node
* @return CurrentUserPrivilegeSet
*/
public static function unserialize(\DOMElement $node)
{
$result = array();
$xprivs = $node->getElementsByTagNameNS('urn:DAV', 'privilege');
for ($jj = 0; $jj < $xprivs->length; $jj++) {
$xpriv = $xprivs->item($jj);
$privilegeName = null;
for ($kk = 0; $kk < $xpriv->childNodes->length; $kk++) {
$childNode = $xpriv->childNodes->item($kk);
if ($t = DAV\XMLUtil::toClarkNotation($childNode)) {
$privilegeName = $t;
break;
}
}
$result[] = $privilegeName;
}
return new self($result);
}
示例12: unserialize
/**
* Unserializes the {DAV:}acl xml element.
*
* @param DOMElement $dom
* @return Sabre_DAVACL_Property_Acl
*/
public static function unserialize(DOMElement $dom)
{
$privileges = array();
$xaces = $dom->getElementsByTagNameNS('urn:DAV', 'ace');
for ($ii = 0; $ii < $xaces->length; $ii++) {
$xace = $xaces->item($ii);
$principal = $xace->getElementsByTagNameNS('urn:DAV', 'principal');
if ($principal->length !== 1) {
throw new Sabre_DAV_Exception_BadRequest('Each {DAV:}ace element must have one {DAV:}principal element');
}
$principal = Sabre_DAVACL_Property_Principal::unserialize($principal->item(0));
if ($principal->getType() !== Sabre_DAVACL_Property_Principal::HREF) {
throw new Sabre_DAV_Exception_NotImplemented('Currently only uri based principals are support, {DAV:}all, {DAV:}unauthenticated and {DAV:}authenticated are not implemented yet');
}
$principal = $principal->getHref();
$protected = false;
if ($xace->getElementsByTagNameNS('urn:DAV', 'protected')->length > 0) {
$protected = true;
}
$grants = $xace->getElementsByTagNameNS('urn:DAV', 'grant');
if ($grants->length < 1) {
throw new Sabre_DAV_Exception_NotImplemented('Every {DAV:}ace element must have a {DAV:}grant element. {DAV:}deny is not yet supported');
}
$grant = $grants->item(0);
$xprivs = $grant->getElementsByTagNameNS('urn:DAV', 'privilege');
for ($jj = 0; $jj < $xprivs->length; $jj++) {
$xpriv = $xprivs->item($jj);
$privilegeName = null;
for ($kk = 0; $kk < $xpriv->childNodes->length; $kk++) {
$childNode = $xpriv->childNodes->item($kk);
if ($t = Sabre_DAV_XMLUtil::toClarkNotation($childNode)) {
$privilegeName = $t;
break;
}
}
if (is_null($privilegeName)) {
throw new Sabre_DAV_Exception_BadRequest('{DAV:}privilege elements must have a privilege element contained within them.');
}
$privileges[] = array('principal' => $principal, 'protected' => $protected, 'privilege' => $privilegeName);
}
}
return new self($privileges);
}
开发者ID:Teino1978-Corp,项目名称:Teino1978-Corp-owncloud_.htaccess-,代码行数:49,代码来源:owncloud_3rdparty_Sabre_DAVACL_Property_Acl.php
示例13: fromXml
/**
* @inheritdoc
*/
public static function fromXml(\DOMElement $element, array $xmlNamespaces = array())
{
$value = array();
foreach ($element->getElementsByTagNameNS('DAV:', 'lockentry') as $xEntry) {
$locktype = null;
$lockscope = null;
// search for WebDAV XML elements
$types = $xEntry->getElementsByTagNameNS('DAV:', 'locktype');
$scopes = $xEntry->getElementsByTagNameNS('DAV:', 'lockscope');
if ($types->length > 0 && $scopes->length > 0) {
$locktype = $types->item(0)->hasChildNodes() ? $types->item(0)->firstChild->localName : null;
$lockscope = $scopes->item(0)->hasChildNodes() ? $scopes->item(0)->firstChild->localName : null;
}
if ($locktype && $lockscope) {
if (!isset($value[$locktype])) {
$value[$locktype] = array();
}
$value[$locktype][] = $lockscope;
}
}
return new self($value);
}
示例14: getChildAttribute
public function getChildAttribute(\DOMElement $node)
{
$name = $node->getAttributeNS($this->namespaces['sv'], 'name');
$type = strtolower($node->getAttributeNS($this->namespaces['sv'], 'type'));
$values = array();
if ($name == 'jcr:created') {
$values[] = date(self::DATEFORMAT);
} else {
foreach ($node->getElementsByTagNameNS($this->namespaces['sv'], 'value') as $nodeValue) {
$values[] = $nodeValue->nodeValue;
}
}
$isMultiValue = false;
if ($name == 'jcr:mixinTypes' || count($values) > 1 || $node->hasAttributeNS($this->namespaces['sv'], 'multiple') && $node->getAttributeNS($this->namespaces['sv'], 'multiple') == 'true') {
$isMultiValue = true;
}
return array($name, array('type' => $type, 'value' => $values, 'multiValued' => $isMultiValue));
}
示例15: parseRoute
/**
* {@inheritdoc}
*/
protected function parseRoute(RouteCollection $collection, \DOMElement $node, $path)
{
if ($this->includeFormat) {
$path = $node->getAttribute('path');
// append format placeholder if not present
if (false === strpos($path, '{_format}')) {
$node->setAttribute('path', $path . '.{_format}');
}
// set format requirement if configured globally
$requirements = $node->getElementsByTagNameNS(self::NAMESPACE_URI, 'requirement');
$format = null;
for ($i = 0; $i < $requirements->length; ++$i) {
$item = $requirements->item($i);
if ($item instanceof \DOMElement && $item->hasAttribute('_format')) {
$format = $item->getAttribute('_format');
break;
}
}
if (null === $format && !empty($this->formats)) {
$requirement = $node->ownerDocument->createElementNs(self::NAMESPACE_URI, 'requirement', implode('|', array_keys($this->formats)));
$requirement->setAttribute('key', '_format');
$node->appendChild($requirement);
}
}
// set the default format if configured
if (null !== $this->defaultFormat) {
$defaultFormatNode = $node->ownerDocument->createElementNS(self::NAMESPACE_URI, 'default', $this->defaultFormat);
$defaultFormatNode->setAttribute('key', '_format');
$node->appendChild($defaultFormatNode);
}
$options = $this->getOptions($node);
foreach ($options as $option) {
$node->appendChild($option);
}
$length = $node->childNodes->length;
for ($i = 0; $i < $length; ++$i) {
$loopNode = $node->childNodes->item($i);
if ($loopNode->nodeType == XML_TEXT_NODE) {
continue;
}
$newNode = $node->ownerDocument->createElementNS(self::NAMESPACE_URI, $loopNode->nodeName, $loopNode->nodeValue);
foreach ($loopNode->attributes as $value) {
$newNode->setAttribute($value->name, $value->value);
}
$node->appendChild($newNode);
}
parent::parseRoute($collection, $node, $path);
}