SYNOPSISxmlNs xmlTreeLookupNsPrefix(xmlNode node, string prefix)
Parameters:
node
- the xmlNode
to lookup the namespace fromprefix
- the prefix of the namespace to lookup
Returns:
prefix
DESCRIPTIONxmlTreeLookupNsPrefix()
looks up the namespace in the scope of
node
that uses the prefix prefix
. Useful if you know
that a namespace exists in the tree but you don't have the
xmlNs
of it.
This does not search the entire XML tree, but only the namespace scope of the given node, which is the current node and all nodes above it. If a namespace isn't available for a node to use, then it won't be found from a search on that node.
For example, given the following document:
<rootNode>
<container xmlns:foo="http://www.example.com/container">
<item1 xmlns:foo="http://www.example.com/item">text</item1>
<item2>text</item2>
</container>
<item3>text</item3>
</rootNode>
If you look up the foo
prefix from:
<item1>
, we'll get http://www.example.com/item
<item2>
, we'll get http://www.example.com/container
<item3>
, we'll get nothing, because the prefix foo
is not defined for <item3>
's scope.
EXAMPLE<$ns = (xmlTreeLookupNsPrefix($node, 'ts'))>
SEE ALSOxmlTreeGetNsURI
,
xmlTreeGetNsPrefix
,
xmlTreeLookupNsURI