def main():
    with manager.connect(host=HOST, port=PORT, username=USER, password=PASS,
                         hostkey_verify=False, device_params={'name': 'nexus'},
                         allow_agent=False, look_for_keys=False) as m:

        # XML filter to issue with the get operation
        hostname_filter = '''
                          <show xmlns="http://www.cisco.com/nxos:1.0">
                              <hostname>
                              </hostname>
                          </show>
                          '''

        result = m.get(('subtree', hostname_filter))
        # Pass the XML result as a string to the parseString function
        xml_doc = xml.dom.minidom.parseString(result.xml)
        hostname = xml_doc.getElementsByTagName("mod:hostname")
        print(hostname[0].firstChild.nodeValue)
Main method that retrieves the hostname from config via NETCONF (NXOS).
dataset/ETHPy150Open CiscoDevNet/netconf-examples/netconf-102/get_hostname.py/main