xmlTreeLookupNsURI

SYNOPSIS

xmlNs xmlTreeLookupNsURI(xmlNode node, string URI)

Parameters:

  • node - the node you want to look up the namespace from

  • URI - the namespace URI you want to look up

Returns:

  • the xmlNs for the URI namespace.


DESCRIPTION
xmlTreeLookupNsURI() looks up a namespace based on the URI, if it exists. Handy if you want to assign a namespace to a node and you need to know if it's already declared in this scope so you don't create an unnecessary duplicate.

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">
        <item1 xmlns:bar="http://www.example.com">text</item1>
        <item2>text</item2>
    </container>
    <item3>text</item3>
</rootNode>

If you look up the http://www.example.com prefix from:

  • <item1>, we'll get bar

  • <item2>, we'll get foo

  • <item3>, we'll get nothing, because the namespace http://www.example.com is not defined for <item3>'s scope.


EXAMPLE

<$ns = (xmlTreeLookupNsURI($node, 'http://www.example.com'))>


SEE ALSO
xmlTreeGetNsURI, xmlTreeGetNsPrefix, xmlTreeLookupNsPrefix


Copyright © Thunderstone Software     Last updated: Apr 15 2024
Copyright © 2024 Thunderstone Software LLC. All rights reserved.