在regex或xpath提取器中按文本查找选项值

如何从下面的响应中通过正则表达式或xpath从文本中提取选项值


xpath提取器


 //*[@id="form_extsss:fromSerie2"]/option[text()='-DRIVE_ME']/@value

例如:


-DRIVE_ME的选项值为630(期望630为最终值)


响应


    <?xml version="1.0" encoding="UTF-8"?>

<partial-response>

   <changes>

      <update id="form_extsss"><![CDATA[<form id="form_extsss" name="form_extsss" 

      method="post" action="" enctype="multipart/form-data">

        <select id="form_extsss:fromSerie2" name="form_extsss:fromSerie2" size="1" onchange="PrimeFaces.ab({s:&quot;form_extsss:fromSerie2&quot;,e:&quot;valueChange&quot;,p:&quot;form_extsss:fromSerie2&quot;,u:&quot;form_extsss&quot;});" style="width:110px">  <option value="-1">Select Series</option>   

        <option value="1384">-HAD</option>  

        <option value="630">-DRIVE_ME</option>

        </select>                       

                                    </form>]]></update>

      <update id="javax.faces.ViewState"><![CDATA[]]></update>

   </changes>

</partial-response>


浮云间
浏览 595回答 2
2回答

万千封印

<option&nbsp;value="630">下面的正则表达式可用于正则表达式提取器: -<option&nbsp;value="(.\d*)">

皈依舞

xpath由于CDATA仅表示为字符串,因此无法使用。但是如果你有xquery可用的话let $x := <partial-response>&nbsp; &nbsp; <changes>&nbsp; &nbsp; &nbsp; <update id="form_extsss"><![CDATA[<form id="form_extsss" name="form_extsss" method="post" action="" enctype="multipart/form-data">&nbsp; &nbsp; &nbsp; <select id="form_extsss:fromSerie2" name="form_extsss:fromSerie2" size="1"&nbsp; onchange="PrimeFaces.ab({s:&quot;form_extsss:fromSerie2&quot;,e:&quot;valueChange&quot;,p:&quot;form_extsss:fromSerie2&quot;,u:&quot;form_extsss&quot;});" style="width:110px">&nbsp; &nbsp; &nbsp; &nbsp; <option value="-1">Select Series</option>&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <option value="1384">-HAD</option>&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <option value="630">-DRIVE_ME</option>&nbsp; &nbsp; &nbsp; </select>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </form>]]></update>&nbsp; &nbsp; &nbsp; <update id="javax.faces.ViewState"><![CDATA[]]></update>&nbsp; &nbsp; </changes>&nbsp; </partial-response>return parse-xml($x/changes/update/text())/form/select/option/@value
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java