Tsung match标记:如何匹配特定的xml标记(服务器响应为xml)

Tsung match标记:如何匹配特定的xml标记(服务器响应为xml),xml,tsung,Xml,Tsung,我正在使用tsung测试一个Web应用程序。当被请求时,服务器用xml响应 我想做的是:如果发生错误,在请求中使用tsung match标记来记录 如果发生错误,xml响应如下所示: <?xml version="1.0" encoding="UTF-8" ?> <toto:root xmlns:toto="toto_url" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <toto:header&

我正在使用tsung测试一个Web应用程序。当被请求时,服务器用xml响应

我想做的是:如果发生错误,在请求中使用tsung match标记来记录

如果发生错误,xml响应如下所示:

<?xml version="1.0" encoding="UTF-8" ?>
 <toto:root xmlns:toto="toto_url" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <toto:header>
  <toto:trace-id>Testing</toto:trace-id>
  <toto:timestamp>1420441279107</toto:timestamp>
  <toto:command>MyServiceName</toto:command>
  <toto:version>2.4</toto:version>
  <toto:operation-id/>
  <toto:calling-user>Tester</toto:calling-user>
  <toto:calling-application>Tester</toto:calling-application>
  <toto:calling-channel/>
  <toto:locale-code>en</toto:locale-code>
  <toto:country-code>EN</toto:country-code>
  <toto:error>
   <toto:applicative>
     <toto:code>002</toto:code>
     <toto:message>No record found</toto:message>
   </toto:applicative>
  </toto:error>
 </toto:header>
 <app:data xmlns:app="url_toto_service">
  <app:totoNullPayload>
    <app:result>OK</app:result>
  </app:totoNullPayload>
</app:data>

测试
1420441279107
我的服务名
2.4
测试员
测试员
EN
EN
002
没有找到任何记录
好啊

我需要为错误代码值002和其他错误代码值登录match.log特定名称

到目前为止,我有这个工作。当我在响应中得到值002时,它会记录在匹配日志中。问题在于,即使它不在标记内,它也与002值匹配。因此,它有时会匹配保存此值的常规xml响应。 002 008

我的问题是如何匹配错误值和它位于标记内部的事实

tsung请求部分是:

   <request subst="true">
            <match name="Norecord" do="log" when="match" skip_headers="http" subst="true">002</match>
    <match name="Request Error" do="log" when="match" skip_headers="http" subst="true">008</match>
   <http url="/myApp/XmlHttpInbound" method="POST" version="1.1"
     content_type="application/xml"
     contents_from_file="/tmp/query.xml">
   </http>

002
008
更新:

Tsung测试计划被指定为xml文件,所以您应该转义响应中预期的xml符号。要匹配标记内的002和008错误代码,您可以使用:

<request subst="true">
    <match do="log" when="match" skip_headers="http" subst="true">&lt;toto:code&gt;002&lt;/toto:code&gt;</match>
    <match do="log" when="match" skip_headers="http" subst="true">&lt;toto:code&gt;008&lt;/toto:code&gt;</match>
    <http url="/myApp/XmlHttpInbound" method="POST" version="1.1"
        content_type="application/xml"
        contents_from_file="/tmp/query.xml">
    </http>
</request>

toto:code002/toto:code
toto:code008/toto:code

请尝试详细说明您的答案,而不是仅仅发布一段代码。解释此代码的工作原理以及选择此解决方案的原因。