当前位置 : 主页 > 网页制作 > xml >

Jmeter Regular Expression Extractor在xml中找到ItemID

来源:互联网 收集:自由互联 发布时间:2021-06-13
我是 jmeter的新手;我希望我能够很好地向你描述我的问题. 我试图使用正则表达式从xml元素中提取ItemID属性.然后我在另一个请求中使用它.这是我试图从中提取ItemID的XML响应: ?xml versio
我是 jmeter的新手;我希望我能够很好地向你描述我的问题.

我试图使用正则表达式从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”的默认值时,它可以正常工作.所以我的表情显然有问题.

试试这个表达式:

\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
--------------------------------------------------------------------------------
  "                        '"'
网友评论