gpt4 book ai didi

xml - Jmeter 正则表达式提取器在 xml 中查找 ItemID

转载 作者:数据小太阳 更新时间:2023-10-29 02:05:15 24 4
gpt4 key购买 nike

我是 的新手;我希望我能向您充分描述我的问题。

我正在尝试使用正则表达式从 xml 元素中提取 ItemID 属性。然后我在另一个请求中使用它。这是我试图从中提取 ItemID 的 XML 响应:

<?xml version="1.0" encoding="UTF-8"?>
<Promise >
<SuggestedOption>
<Option TotalShipments="1">
<PromiseLines TotalNumberOfRecords="1">
<PromiseLine ItemID="Col_001" >
<Assignments>
<Assignment InteractionNo="1" >
</Assignment>
</Assignments>
</PromiseLine>
</PromiseLines>
</Option>
</SuggestedOption>
</Promise>

我的正则表达式提取器设置如下:

Reference Name: item
Regular Expression: .?ItemID=(.+?)*
Template: $1$
Match No.: 1

在第二个请求中,我将 ItemID 设置如下 ... ItemID=${item} ...

我知道当我使用设置为“Col_001”的默认值时它工作正常。所以很明显我的Expression有问题。

最佳答案

试试这个表达式:

\bItemID\s*=\s*"([^"]*)"

解释

NODE                     EXPLANATION
--------------------------------------------------------------------------------
\b the boundary between a word char (\w) and
something that is not a word char
--------------------------------------------------------------------------------
ItemID 'ItemID'
--------------------------------------------------------------------------------
\s* whitespace (\n, \r, \t, \f, and " ") (0 or
more times (matching the most amount
possible))
--------------------------------------------------------------------------------
= '='
--------------------------------------------------------------------------------
\s* whitespace (\n, \r, \t, \f, and " ") (0 or
more times (matching the most amount
possible))
--------------------------------------------------------------------------------
" '"'
--------------------------------------------------------------------------------
( group and capture to \1:
--------------------------------------------------------------------------------
[^"]* any character except: '"' (0 or more
times (matching the most amount
possible))
--------------------------------------------------------------------------------
) end of \1
--------------------------------------------------------------------------------
" '"'

关于xml - Jmeter 正则表达式提取器在 xml 中查找 ItemID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13224425/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com