How to insert an attribute into XML root node in Loadrunner using lr_xml_insert()

允我心安 提交于 2020-01-15 16:51:46

问题


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

Code Fragment:

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}"));

Desired output:

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

Actual Loadrunner output

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

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


回答1:


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.



来源:https://stackoverflow.com/questions/25509383/how-to-insert-an-attribute-into-xml-root-node-in-loadrunner-using-lr-xml-insert

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!