xml_ – XML handling

Methods for creating, parsing, and dealing with XML and ElementTree objects.

exception ncclient.xml_.XMLError

Bases: ncclient.NCClientError


ncclient.xml_.BASE_NS_1_0 = 'urn:ietf:params:xml:ns:netconf:base:1.0'

Base NETCONF namespace

ncclient.xml_.TAILF_AAA_1_1 = 'http://tail-f.com/ns/aaa/1.1'

Namespace for Tail-f core data model

ncclient.xml_.TAILF_EXECD_1_1 = 'http://tail-f.com/ns/execd/1.1'

Namespace for Tail-f execd data model

ncclient.xml_.CISCO_CPI_1_0 = 'http://www.cisco.com/cpi_10/schema'

Namespace for Cisco data model

ncclient.xml_.JUNIPER_1_1 = 'http://xml.juniper.net/xnm/1.1/xnm'

Namespace for Juniper 9.6R4. Tested with Junos 9.6R4+

ncclient.xml_.FLOWMON_1_0 = 'http://www.liberouter.org/ns/netopeer/flowmon/1.0'

Namespace for Flowmon data model

ncclient.xml_.register_namespace(prefix, uri)

Registers a namespace prefix that newly created Elements in that namespace will use. The registry is global, and any existing mapping for either the given prefix or the namespace URI will be removed.

ncclient.xml_.qualify(tag, ns='urn:ietf:params:xml:ns:netconf:base:1.0')

Qualify a tag name with a namespace, in ElementTree fashion i.e. {namespace}tagname.


ncclient.xml_.to_xml(ele, encoding='UTF-8', pretty_print=False)

Convert and return the XML for an ele (Element) with specified encoding.


Convert and return the Element for the XML document x. If x is already an Element simply returns that.


Efficiently parses the root element of a raw XML document, returning a tuple of its qualified name and attribute dictionary.

ncclient.xml_.validated_element(x, tags=None, attrs=None)

Checks if the root element of an XML document or Element meets the supplied criteria.

tags if specified is either a single allowable tag name or sequence of allowable alternatives

attrs if specified is a sequence of required attributes, each of which may be a sequence of several allowable alternatives

Raises XMLError if the requirements are not met.