本文整理匯總了PHP中DomDocument::getDefaultNamespaceUri方法的典型用法代碼示例。如果您正苦於以下問題:PHP DomDocument::getDefaultNamespaceUri方法的具體用法?PHP DomDocument::getDefaultNamespaceUri怎麽用?PHP DomDocument::getDefaultNamespaceUri使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DomDocument
的用法示例。
在下文中一共展示了DomDocument::getDefaultNamespaceUri方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getChildren
/**
* Returns all child elements of the given name. Special handling for the following names is implemented:
* - 'paramaters' returns all direct 'parameters' OR all 'parameters/parameter' child nodes
* - 'formatters' returns all direct 'formatters' OR all 'formatters/formatter' child nodes
*
* @param string $name name of child element
*
* @return \DOMNodeList of all child elements with the given name in the default namespace
*/
public function getChildren($name)
{
$query = '';
$singular_name = null;
// special nodes of environaut config files where the surrounding plural node
// may be omitted and the singular nodes be used directly (for less verbose xml)
if (in_array($name, array('parameters', 'formatters'))) {
if ($name === 'parameters') {
$singular_name = 'parameter';
} elseif ($name === 'formatters') {
$singular_name = 'formatter';
}
$query = 'child::*[local-name() = "%2$s" and namespace-uri() = "%3$s"] | ' . 'child::*[local-name() = "%1$s" and namespace-uri() = "%3$s"]/*' . '[local-name() = "%2$s" and namespace-uri() = "%3$s"]';
} else {
$query = 'child::*[local-name() = "%1$s" and namespace-uri() = "%3$s"]';
}
$nodes = $this->ownerDocument->getXpath()->query(sprintf($query, $name, $singular_name, $this->ownerDocument->getDefaultNamespaceUri()), $this);
return $nodes;
}