Hi, I’m using robotframework-ncclient · PyPI to connect to a router using netconf.
when doing a netconf Get, I’m putting the response into a variable and I have figured that the variable content type is lxml.etree_Element. see below:
Evaluating expression <Element {urn:ietf:params:xml:ns:netconf:base:1.0}data at 0x7f9d80ff1200> failed: TypeError: Expression must be string, got Element.
this is the content of the response:
${res} = <Element {urn:ietf:params:xml:ns:netconf:base:1.0}data at 0x7f57567c9980>
I have used a few things to try to get it working but they both give me the same error for example:
${xml_string} = Evaluate lxml.tostring(${res}, encoding='unicode', pretty_print=True) modules=lxml.etree
and
${xml_string} = Evaluate ${res}.xpath("//version-number", namespaces={'nc': 'urn:ietf:params:xml:ns:netconf:base:1.0'})[0].text modules=lxml.etree
This is the usual error I get:
Evaluating expression "lxml.tostring(<Element {urn:ietf:params:xml:ns:netconf:base:1.0}data at 0x7f4d4a5d8dc0>, encoding='unicode', pretty_print=True)" failed: SyntaxError: invalid syntax (<string>, line 1)
and
Evaluating expression '<Element {urn:ietf:params:xml:ns:netconf:base:1.0}data at 0x7feb95edf640>.xpath("//version-number", namespaces={\'nc\': \'urn:ietf:params:xml:ns:netconf:base:1.0\'})[0].text' failed: SyntaxError: invalid syntax (<string>, line 1)
any Ideas on what I’m doing wrong? and how to parse the content of this xml variable?
Thank you!