获取元素文本不返回 xml 文件中的值

Get Element Text not returning value in xml file

我的XML文件如下

<configuration commit-localtime="2020-09-21 14:53:21 PDT" commit-seconds="1600725201" commit-user="root">
    <comment># End of the data from file (/volume/labtools/lab_cvs/system-test/machine/.global/lab_routes-config)</comment>
    <groups>
        <name>vrrp_ipv4_all</name>
        <interfaces>
            <interface>
                <name>&lt;*&gt;</name>
                <unit>
                    <name>&lt;*&gt;</name>
                    <family>
                        <inet>
                            <address>
                                <name>&lt;*&gt;</name>
                                <vrrp-group>
                                    <name>&lt;*&gt;</name>
                                    <priority>201</priority>
                                    <fast-interval>1000</fast-interval>
                                </vrrp-group>
                            </address>
                        </inet>
                    </family>
                </unit>
            </interface>
        </interfaces>
    </groups>
</configuration>

我在机器人框架中使用如下命令

获取元素文本 ${output} //优先级

但我得到的错误是

语法错误:不能在元素上使用绝对路径

我想我需要使用 .//priority 但我无法理解这背后的原因。由于此输出中已经存在优先级,为什么我需要添加 [.] 来指示当前节点? 请帮忙!

Get Element Text Robotframework XML 库命令的上下文中,XPath 必须相对于 source 节点(${output} in你的情况)。那里不允许使用绝对 XPath。