本文介绍了如何使用lr_xml_insert()将属性插入Loadrunner中的XML根节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用lr_xml_insert函数将属性插入到loadrunner中XML片段的根节点中.

I'm trying to insert an attribute into the root node of an XML fragment in loadrunner, using the lr_xml_insert function.

代码片段:

char *inputXML=
     "<a>"
        "<b>"
            "<c></c>"
        "</b>"
     "</a>";

lr_save_string(inputXML,"paramInputXML");

lr_xml_insert("Xml={paramInputXML}",
              "Query=/a",
              "ResultParam=Result",
              "Position=attribute",
              "XmlFragment=attribValue=\"0\"",
              LAST);
lr_output_message(lr_eval_string("String after insertion: {Result}"));

所需的输出:

String after insertion: <a attribValue="0"><b><c/></b></a>

Loadrunner的实际输出

Actual Loadrunner output

String after insertion: <a><b><c/></b>attribValue="0"</a>

如果xpath查询是/a/b或/a/b/c而不是/a,则该函数的行为符合预期

The function behaves as expected if the xpath query is /a/b or /a/b/c instead of /a

推荐答案

我检查了产品代码(12.01)中的问题,这似乎是此情况下的特定产品问题.看来,当选择了根元素会自动改变位置参数孩子".我在内部系统中发现了一个缺陷.

I checked the issue within the product code (12.01) and it seems to be a product issue specific to this case. It seems that when the root element is selected it automatically changes the Position argument to 'child'. I have opened a defect in our internal systems.

非常感谢您发现此问题.

Thank you very much for finding this issue.

这篇关于如何使用lr_xml_insert()将属性插入Loadrunner中的XML根节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 12:09