如何在RobotFramework-RobotFramework中解析带前缀的XML

Lynn
Lynn
订阅者
223
文章
0
粉丝
测试交流1 276字数 337阅读1分7秒阅读模式
摘要我有以下XML 输入XML 什么xml版本="1.0“;编码=“”;UTF-8&燃气轮机; <名称空间:RAIseQuery xmlns:N...

我有以下XML

输入XML文章源自玩技e族-https://www.playezu.com/180896.html

<?xml version="1.0" encoding="UTF-8"?>
<NAMESPACE:RAIseQuery xmlns:NAMESPACE="urn:NAMESPACE:xsd:$RAIseQuery" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:NAMESPACE:xsd:$RAIseQuery RAIseQuery.xsd">
    <NAMESPACE:Sender>ABCDEF</NAMESPACE:Sender>
    <NAMESPACE:Received>PQRSTUV</NAMESPACE:Received>
    <NAMESPACE:Ref>ABC12345678</NAMESPACE:Ref>   
    <NAMESPACE:Waitforrevert xmlns="urn:xyz:std:xyz:2022:tech:xsd:abcd.123.001.01">
        <START1>
            <Id>PQRTSUV12345678910</Id>
        </START1>
    </NAMESPACE:Waitforrevert>
</NAMESPACE:RAIseQuery>

预期输出文章源自玩技e族-https://www.playezu.com/180896.html

<?xml version="1.0" encoding="UTF-8"?>
<NAMESPACE:RAIseQuery xmlns:NAMESPACE="urn:NAMESPACE:xsd:$RAIseQuery" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:NAMESPACE:xsd:$RAIseQuery RAIseQuery.xsd">
    <NAMESPACE:Sender>ABCDEF</NAMESPACE:Sender>
    <NAMESPACE:Received>PQRSTUV</NAMESPACE:Received>
    <NAMESPACE:Ref>XYZ2345678</NAMESPACE:Ref>   
    <NAMESPACE:Waitforrevert xmlns="urn:xyz:std:xyz:2022:tech:xsd:abcd.123.001.01">
        <START1>
            <Id>DEFGSUV12345678910</Id>
        </START1>
    </NAMESPACE:Waitforrevert>
</NAMESPACE:RAIseQuery>

我试图为我的测试用例编辑XML,并在Robotframework中使用了以下内容。文章源自玩技e族-https://www.playezu.com/180896.html

*** Settings ***
Library     XML use_lxml=yes
*** Test Cases ***
xml_with_namespace
    ${y}=   Parse   Xml ${IN_The_Path}
    Set Element Text    ${y}    XYZ2345678  xpath=.//NAMESPACE:Ref
    Set Element Text    ${y}    DEFGSUV12345678910xpath=.///NAMESPACE:Waitforrevert/START1/Id
    Save Xml    ${y}    ${Path2}

但我得到以下错误。我不知道如何处理前缀和名称空间在径向基函数和新的使用这个库。文章源自玩技e族-https://www.playezu.com/180896.html

错误-语法错误:在前缀映射中找不到前缀“NAMESPACE”文章源自玩技e族-https://www.playezu.com/180896.html 文章源自玩技e族-https://www.playezu.com/180896.html

 
    • Defandi
      Defandi 9

      尝试以下Xpath:
      xpath:/NAMESPACE:RAIseQuery/NAMESPACE:Ref 和
      xpath:/NAMESPACE:RAIseQuery/NAMESPACE:Waitforrevert/START1/Id

    匿名

    发表评论

    匿名网友
    确定

    拖动滑块以完成验证