本文整理汇总了PHP中DOMNode::getAttributeNS方法的典型用法代码示例。如果您正苦于以下问题:PHP DOMNode::getAttributeNS方法的具体用法?PHP DOMNode::getAttributeNS怎么用?PHP DOMNode::getAttributeNS使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DOMNode
的用法示例。
在下文中一共展示了DOMNode::getAttributeNS方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: AddXsiType
/**
* Adds the xsi:type to the DOMNode generated from the corresponding object.
* @param DOMNode $domNode the DOM node corresponding to the object
* @param $object the object used to determine the xsi:type
* @access private
*/
private function AddXsiType(DOMNode $domNode, $object)
{
$xsiType = $domNode->getAttributeNS(self::$XSI_NAMESPACE, 'xsi:type');
if (method_exists($object, 'getXsiTypeName') && method_exists($object, 'getNamespace') && empty($xsiType)) {
$xsiTypeName = $object->getXsiTypeName();
if (isset($xsiTypeName) && $xsiTypeName != '') {
$prefix = $domNode->lookupPrefix($object->getNamespace());
$domNode->setAttributeNS(self::$XSI_NAMESPACE, 'xsi:type', (isset($prefix) ? $prefix . ':' : '') . $xsiTypeName);
}
}
}
示例2: transferArrayTo
/**
* Transfer an array value into a target element node. Sets the json:type attribute to 'array' and
* creates child element nodes for each array element using the default QName.
*
* @param \DOMNode|\DOMElement|\DOMDocumentFragment $target
* @param array $value
* @param int $recursions
*/
private function transferArrayTo(\DOMNode $target, array $value, $recursions)
{
$parentName = '';
if ($target instanceof Element) {
$target->setAttributeNS(self::XMLNS, 'json:type', 'array');
$parentName = $target->getAttributeNS(self::XMLNS, 'name') ?: $target->localName;
}
foreach ($value as $item) {
$target->appendChild($child = $target->ownerDocument->createElement($this->getQualifiedName($parentName, self::DEFAULT_QNAME, TRUE)));
$this->transferTo($child, $item, $recursions);
}
}