xml_ – XML handling

exception ncclient.xml_.XMLError
Bases: ncclient.NCClientError

Namespaces

ncclient.xml_.BASE_NS_1_0
Base NETCONF namespace
ncclient.xml_.TAILF_AAA_1_1
Namespace for Tail-f core data model
ncclient.xml_.TAILF_EXECD_1_1
Namespace for Tail-f execd data model
ncclient.xml_.CISCO_CPI_1_0
Namespace for Cisco data model
ncclient.xml_.FLOWMON_1_0
Namespace for Flowmon data model
ncclient.xml_.register_namespace(prefix, uri)
ElementTree’s namespace map determines the prefixes for namespace URI’s when serializing to XML. This method allows modifying this map to specify a prefix for a namespace URI.
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.

Parameters:
  • tag – name of the tag
  • ns (string) – namespace to qualify with

Conversion

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

Convert an Element to XML.

Parameters:
  • ele – the Element
  • encoding – character encoding
Return type:

string

ncclient.xml_.to_ele(x)

Convert XML to Element. If passed an Element simply returns that.

Parameter:x (string or Element) – the XML document or element
Return type:Element
ncclient.xml_.parse_root(raw)

Efficiently parses the root element of an XML document.

Parameter:raw – XML document
Returns:a tuple of (tag, attrib), where tag is the (qualified) name of the element and attrib is a dictionary of its attributes.
Return type:tuple
ncclient.xml_.validated_element(x, tags=None, attrs=None)

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

Parameters:
  • tags (string or sequence of strings) – allowable tag name or sequence of allowable alternatives
  • attrs (sequence of strings or sequence of sequences of strings) – list of required attributes, each of which may be a sequence of several allowable alternatives
Raises:

XMLError if the requirements are not met

Table Of Contents

Previous topic

capabilities – NETCONF Capabilities

Next topic

transport – Transport / Session layer

This Page