Ayub Ait
Ayub Ait

Reputation: 13

HOW GET ELEMENT which has the maximum childs in XPATH?

I created one table with number of columns. Now i want to get column name which have maximum number of element. How do get that result in xpath query?

Example Code:

<table>
            <colum>

                <namecolum>aaa</namecolum>
                <td>12</td>
                <td>22</td>
                <td>11</td>
            </colum>
            <colum>

                <namecolum>bbbb</namecolum>
                <td>33</td>  
                <td>423</td>
            </colum>
            <colum>
                <namecolum>cccc</namecolum>
                <td>323</td>
                <td>212</td>
                <td>00</td>
                <td>667</td>
             </colum>
 </table>

Any other code is appreciable if any one can provide me.Thanks in advance.

Upvotes: 1

Views: 605

Answers (1)

splash58
splash58

Reputation: 26153

You can select colum such that there is no colum with more amount of td tags

//colum[not(count(td) < //colum/count(td))]/namecolum/text()

Upvotes: 3

Related Questions