具有多个标签的XML的XPATH

时间:2018-07-27 11:12:57

标签: xpath

我在XML下面,我想为标签元素获取XPATH-

<?xml version="1.0"?>
<perf-config>
    <server name="Server1" version="V2" />
    <performance-data>
    <buttons>YES</buttons>
    <metric id="8D1180" description="response time " type="multi" listtype="P" >
        <timerange localstart="20180727110300" localend="20180727110400" utcstart="20180727090300" utcend="20180727090400"/>
        <scroll prev="20180727110230" next="20180727110430"/>
        <gathererinterval seconds="60"/>
        <data-range seconds="60"/>
        <row label="stc01" value="0.19" per="100" ex="NONE"/>
        <row label="stc02" value="0.097" per="51.0526" ex="NONE"/>
        <row label="stc03.1" value="0.01" per="5.26316" ex="NONE"/>
        <row label="stc03.2" value="0.001" per="0.526316" ex="NONE"/>
    </metric>
    </performance-data>
</perf-config>What would be XPATH for label stc01, stc02...

我在下面尝试过,但没有帮助。

/perf-config/performance-data/metric/label[text()='stc01']

我能够获得如下所示的xpath

/perf-config/performance-data/metric/row[@label="stc01"]

输出为

  

Element = '<row ex="NONE" label="stc01" per="100" value="0.19"/>'

接下来,我要从此xpath获取“值”的数据

1 个答案:

答案 0 :(得分:2)

尝试在XPath下获取所需的输出:

<div class="card" style="width: 18rem;">
  <img class="card-img-top" src="..." alt="Card image cap">
  <div class="card-body">
    <h5 class="card-title">Card title</h5>
    <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
    <a href="#" class="btn btn-primary">Go somewhere</a>
  </div>