使用SOAPUI中的groovy在XML响应中使用自定义字段查找html值

时间:2017-05-12 13:34:34

标签: xml groovy soapui

在SOAPUI XML Response中,我有一个如下元素:

<div class="field-group aui-field-cascadingselect">
                       <label for="customfield_1">
                          Project
                          <span class="aui-icon icon-required">GitHmc</span>
                       </label>
                       <select class="select cascadingselect-parent" id="customfield_1" name="customfield_1">
                          <option class="default-option" value="">Task</option>
                          <option class="option-group-210" value="210">Task1</option>
                          <option class="option-group-813" value="813">Task2</option>
                          <option class="option-group-213" value="213" selected="selected">Task3</option>
                          <option class="option-group-214" value="214">Task4</option>
                          <option class="option-group-215" value="215">Task5</option>
                          <option class="option-group-216" value="216">Task6</option>
                       </select>
                       <select class="select cascadingselect-child" id="customfield_1:1" name="customfield_1:1">
                          <option class="default-option" value="">Data</option>
                          <option class="option-group-210" value="">Data1</option>
                          <option class="option-group-813" value="">Data2</option>
                          <option class="option-group-211" value="">Data3</option>
                          <option class="option-group-213" value="">Data4</option>
                          <option class="option-group-213" value="417">Data5</option>
                          <option class="option-group-213" value="1311">Data6</option>
                          <option class="option-group-213" value="223">Data7</option>
                          <option class="option-group-213" value="711">Data8</option>
                          <option class="option-group-213" value="010" selected="selected">Data9</option>
                          <option class="option-group-213" value="410">Data10</option>
                       </select>

我需要从所选选项中获取值:

<option class="option-group-213" value="213" selected="selected">Task3</option>

<option class="option-group-213" value="010" selected="selected">Data9</option>

如何使用Groovy脚本获取此2值?

有人可以让我知道如何使这项工作?

1 个答案:

答案 0 :(得分:1)

您可以使用XmlParserhttp://groovy-lang.org/processing-xml.html

解析XML