PHP XPATH within changing XML structure -


i've xml file this:

<tr class="station">     <td class="realtime">      <span>       15:11      </span>   </td>  </tr>  <tr class="station">     <td class="clock">      15:20    </td>  </tr>  <tr class="station">     <td class="clock">      15:30    </td>  </tr>  <tr class="station">     <td class="realtime">      <span>       15:41      </span>   </td>  </tr> 

and wanna parse xpath in php. xml been updated , parsed quite often.
want first time (in case 15:11)
problem not sure whether surrounding tag td class "clock" or "realtime".
if there surrounding realtime, there span tag within. otherwise not.
in fact, first "station"-class tag in information is, matters. possible tell xpath evaluate within tag?
there method doing in xpath?
(sry bad english)

in fact, first "station"-class tag in information is, matters. possible tell xpath evaluate within tag?

with wellformed input source:

<table>     <tr class="station">         <td class="realtime">             <span>                 15:41             </span>         </td>     </tr>     <tr class="station">         <td class="clock">             15:20         </td>     </tr>     <tr class="station">         <td class="clock">             15:30         </td>     </tr>     <tr class="station">         <td class="realtime">             <span>                 15:41             </span>         </td>     </tr> </table> 

this xpath expression:

/table/tr[@class='station'][1]/td 

note: select element want , use proper dom api method string value. doesn't matter whether there span element or not.

if want to...

/table/tr[@class='station'][1]/td//text() 

Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -