What will be the Xpath of this XML for PHP Dom Document use? -


i have xml in format,

<tbody>     <tr>         <td>a</td>         <tr>             <td>b</td>             <tr>                 <td>c</td>             </tr>             <td>d</td>         </tr>     </tr> </tbody> 

here have consider b , d child of a, c child of b. c , d have no child nodes.

i want retrieve last nodes of hierarchy doesn't have more child nodes <td>c</td> , <td>d</td>etc inside <tr> , replace value of 'td' 'th'. using xpath query "//*[not(child::*)]" retrieves leaf nodes , b well. can best way use xpath query easily? in advance.

edit: tags tr , td representation purpose , not used in original code.

it seem want leaf nodes have no following sibling:

//*[not(child::*) , not(following-sibling::*)] 

Comments

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -

recursion - Can every recursive algorithm be improved with dynamic programming? -