views:

31

answers:

2

I'm trying to pull the text between the nobr tags.

This is part of the table:

       <table class="report-main-table dirLTR NormalTxt" width="100%" border="0" cellspacing="0" cellpadding="0">

<thead>

<tr>

<td class="report-data-title-cell report-data-column-odd"><nobr><b>&#1505;&#1492;"&#1499; &#1506;&#1500;&#1493;&#1514; &#1489;&#1513;"&#1495;</b></nobr></td><td class="report-data-title-cell report-data-column-even"><nobr><b>&#1497;&#1506;&#1491; &#1492;&#1513;&#1497;&#1495;&#1492;</b></nobr></td><td class="report-data-title-cell report-data-column-odd"><nobr><b>&#1505;&#1493;&#1490; &#1513;&#1497;&#1495;&#1492;</b></nobr></td><td class="report-data-title-cell report-data-column-even"><nobr><b>&#1505;&#1492;"&#1499; &#1494;&#1502;&#1503; &#1488;&#1493;&#1497;&#1512; &#1500;&#1495;&#1497;&#1493;&#1489;</b></nobr></td><td class="report-data-title-cell report-data-column-odd"><nobr><b>&#1492;&#1502;&#1505;&#1508;&#1512; &#1513;&#1495;&#1493;&#1497;&#1490;</b></nobr></td><td class="report-data-title-cell report-data-column-even"><nobr><b>&#1513;&#1506;&#1514; &#1513;&#1497;&#1495;&#1492;</b></nobr></td><td class="report-data-title-cell report-data-column-odd"><nobr><b>&#1514;&#1488;&#1512;&#1497;&#1498; &#1513;&#1497;&#1495;&#1492;</b></nobr></td>

</tr>

</thead>

<tr class="report-data-row-even">

<td class="NormalTxt report-data-cell report-data-column-even"><nobr>0.0285</nobr></td><td class="NormalTxt report-data-cell report-data-column-odd"><nobr>&#1508;&#1512;&#1496;&#1504;&#1512;</nobr></td><td class="NormalTxt report-data-cell report-data-column-even"><nobr>SMS</nobr></td><td class="NormalTxt report-data-cell report-data-column-odd"><nobr>1</nobr></td><td class="NormalTxt report-data-cell report-data-column-even"><nobr>054-2570130</nobr></td><td class="NormalTxt report-data-cell report-data-column-odd"><nobr>00:14:09</nobr></td><td class="NormalTxt report-data-cell report-data-column-even"><nobr>27/09/2010</nobr></td>

</tr>

<tr class="report-data-row-odd">

<td class="NormalTxt report-data-cell report-data-column-even"><nobr>0.0000</nobr></td><td class="NormalTxt report-data-cell report-data-column-odd"><nobr>&#1505;&#1500;&#1511;&#1493;&#1501;</nobr></td><td class="NormalTxt report-data-cell report-data-column-even"><nobr>SMS</nobr></td><td class="NormalTxt report-data-cell report-data-column-odd"><nobr>1</nobr></td><td class="NormalTxt report-data-cell report-data-column-even"><nobr>052-3669127</nobr></td><td class="NormalTxt report-data-cell report-data-column-odd"><nobr>00:47:25</nobr></td><td class="NormalTxt report-data-cell report-data-column-even"><nobr>27/09/2010</nobr></td>

</tr>

I was trying this xpath expression://table/tr/td/nobr/, but this did not work.

What is the correct xpath expression?

Thanks

A: 

Try //table//td/nobr.

EDIT: As requested, here's the expression logic.

We're looking for the inner text of the nobr elements (nobr)

  • that are inside table cells (td/nobr),
  • that are descendants of all tables in the document (//table//td/nobr: here we skip the tr elements and the thead, tbody and tfoot elements that may occur between the table and td elements.
Frédéric Hamidi
Thanks, this works, how did you come with this expression?what was the logic?
embedded
A: 

Use:

//nobr

This may be more efficient than:

//table//td/nobr

because the // abbreviation causes a complete traversal of the tree rooted in the current node and we have the // abbreviation only once in the former expression but twice in the latter expression.

Always try to avoid using the // abbreviation, when you know the structure of the XML document.

Dimitre Novatchev