我有一个robot命令的输出,它是xml标量变量,比如${xml}。 如何在Robot框架中解析xml来获取和验证ipv4地址的值?
<rpc-reply
xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"
message-id="101">
<data xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-datastores">
<interfaces
xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces"
xmlns:ianaift="urn:ietf:params:xml:ns:yang:iana-if-type"
xmlns:or="urn:ietf:params:xml:ns:yang:ietf-origin">
<interface or:origin="or:intended">
<name>eth0</name>
<type>ianaift:ethernetCsmacd</type>
<!-- other parameters from ietf-interfaces omitted -->
<ipv4 xmlns="urn:ietf:params:xml:ns:yang:ietf-ip">
<enabled or:origin="or:default">true</enabled>
<forwarding or:origin="or:default">false</forwarding>
<mtu or:origin="or:system">1500</mtu>
<address>
<ip>192.0.2.1</ip>
首先,您的XML是无效的,因为它没有结束标记。我更正了它,这是XML。你知道吗
你知道吗IP地址.xml你知道吗
测试文件本身:
你知道吗XMLTest.robot机器人你知道吗
当我运行它时:
robot XMLTest.robot
输出为:
应该可以了!你知道吗
相关问题 更多 >
编程相关推荐