如何写一个xpath来查找里面的标签只是<refint>而不是其他标签</refint>

时间:2015-01-28 06:59:50

标签: xml xpath

INPUT

<TABLE>
    <THEAD>
    <ROW id="rh">
    <CELL rowmerged="F"  rowspan="1" >
        <Para ><refint>REFINT1</refint>A</Para>
    </CELL>
        <CELL rowmerged="F"  rowspan="1" >
            <Para >B<refint>REFINT2</refint></Para>
        </CELL>
        <CELL rowmerged="F"  rowspan="1" >
            <Para >C<notrefint>REFINT1</notrefint></Para>
        </CELL>
        <CELL rowmerged="F"  rowspan="1" >
            <Para >D</Para>
        </CELL>
        <CELL rowmerged="F"  rowspan="1" >
            <Para >F</Para>
        </CELL>
    </ROW>


</THEAD>
<TBODY editable="T">
    <ROW id="r1">
        <CELL rowmerged="T"  rowspan="2" >
            <Para >11</Para>
        </CELL>
        <CELL rowmerged="T"  rowspan="2" >
            <Para >12</Para>
        </CELL>
        <CELL rowmerged="F"  rowspan="1" >
            <Para >13</Para>
        </CELL>
        <CELL rowmerged="F"  rowspan="1" >
            <Para >14</Para>
        </CELL>
        <CELL rowmerged="T"  rowspan="2" >
            <Para >15</Para>
        </CELL>
    </ROW>

    <ROW id="r2">
        <CELL rowmerged="T"  rowspan="2" >
            <Para ></Para>
        </CELL>
        <CELL rowmerged="T"  rowspan="2" >
            <Para ></Para>
        </CELL>
        <CELL rowmerged="F"  rowspan="1" >
            <Para >23</Para>
        </CELL>
        <CELL rowmerged="F"  rowspan="1" >
            <Para >24</Para>
        </CELL>
        <CELL rowmerged="T"  rowspan="2" >
            <Para ></Para>
        </CELL>
    </ROW>

    <ROW id="r3">
        <CELL rowmerged="T"  rowspan="2" >
            <Para ></Para>
        </CELL>
        <CELL rowmerged="T"  rowspan="2" >
            <Para ></Para>
        </CELL>
        <CELL rowmerged="F"  rowspan="1" >
            <Para >33</Para>
        </CELL>
        <CELL rowmerged="F"  rowspan="1" >
            <Para >34</Para>
        </CELL>
        <CELL rowmerged="T"  rowspan="2" >
            <Para ></Para>
        </CELL>
    </ROW>

    <ROW id="r4">
        <CELL rowmerged="F"  rowspan="1" >
            <Para >41</Para>
        </CELL>
        <CELL rowmerged="F"  rowspan="1" >
            <Para >42</Para>
        </CELL>
        <CELL rowmerged="F"  rowspan="1" >
            <Para >43</Para>
        </CELL>
        <CELL rowmerged="F"  rowspan="1" >
            <Para >44</Para>
        </CELL>
        <CELL rowmerged="T"  rowspan="1" >
            <Para >45</Para>
        </CELL>
    </ROW>
    </TBODY>
</TABLE>

我是xpath的新手,并且不知道如何在xpath中写入条件来获取THEAD中的内部标记只是<refint></refint>而不是其他标签。 如何写一个xpath来查找里面的标签只是<refint>而不是其他标签

我需要一个解决方案来获取THEAD中的内部标记是否为<refint>

1 个答案:

答案 0 :(得分:0)

也许这个?

/TABLE/THEAD/ROW/CELL[1]/Para/refint

还是这个?

/TABLE/THEAD/.//refint

我认为问题有点模糊