0
 <checkpoints checkpoint_count="1">
      <checkpoint checkpoint_name="New CheckPoint" ignore_blank_lines="false" modified_complexity="false" checkpoint_date="1999-08-31">         
          <file file_name="Plugin.java">
            <metrics metric_count="15">
              <metric id="M0">57</metric>
              <metric id="M1">17</metric>
              <metric id="M2">0.0</metric>
              <metric id="M3">3</metric>
              <metric id="M4">47.4</metric>
              <metric id="M5">1</metric>
              <metric id="M6">5.00</metric>
              <metric id="M7">1.20</metric>
              <metric id="M8">20</metric>
              <metric id="M9">CheatsheetsPlugin.getImageDescriptor()</metric>
              <metric id="M10">1</metric>
              <metric id="M11">21</metric>
              <metric id="M12">2</metric>
              <metric id="M13">1.05</metric>
              <metric id="M14">1.00</metric>
            </metrics>
        </file>
 </checkpoint>
</checkpoints>

This is my xml file. I want to read value of metric id='M14'. ie. 1.00
How to read the content of this tag?

4

1 回答 1

0

Use:

/*/*/*/*/metric[@id = 'M14']/text()

This selects any child text node (in this case just one) of any metric element that is a grand-grand-child of the top element and whose (of the metric element) id attribute has as string value the string 'M14'.

于 2012-12-03T13:24:44.007 回答