xmlTreeClearNs

SYNOPSIS

int xmlTreeClearNs(xmlNs ns)

Parameters:

  • ns - the namespace to clear

Returns:

  • 0 - success

  • <0 - error


DESCRIPTION
xmlTreeClearNs() clears the prefix and URI of a namespace. It is not technically deleted, but a cleared namespace does not show up at all in the output. It can be made to show again by setting the prefix or URI.


EXAMPLE
Given the XML document

<foo:rootNode xmlns:foo="http://www.example.com/foo"
              xmlns:bar="http:/www.example.com/bar">
    <foo:item>a foo-y item</foo:item>
    <bar:item>a bar-y item with different flavor</bar:item>
</foo:rootNode>

and $bar is the <bar> element, then calling

<$ns = (xmlTreeGetNs($bar))>
    <$ret = (xmlTreeClearNs($ns))>

and printing the document will give:

<foo:rootNode xmlns:foo="http://www.example.com/foo">
    <foo:item>a foo-y item</foo:item>
    <item>a bar-y item with different flavor</item>
</foo:rootNode>


CAVEATS
Clearing a namespace and then setting a prefix without setting a URI will result in an XML document that is not well-formed. For example, starting from the following XML document:

<myns:top xmlns:myns="urn:MyNamespace"/>

If you can xmlTreeClearNs() and set the prefix to new (via xmlTreeSetPrefix()), you will end up with:

<new:top/>

This not a well-formed XML document because the new namespace is being used without being declared.


SEE ALSO
xmlTreeSetNsPrefix, xmlTreeSetNsURI


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