I am trying to use xPath to traverse through the code of a newspaper (for the sake of practice) right now I'd like to get the main article, it's picture and the small description I get of it. But I'm not that skilled in xPath so far and I can't get to the small description.
withing this code:
<div class="margenesPortlet">
<div class="fondoprincipal">
<div class="margenesPortlet">
<a href='notas/n1092329.htm' ><img id="LinkNotaA1_Foto" src="http://i.oem.com.mx/5cfaf266-bb93-436c-82bc-b60a78d21fb6.jpg" height="250" width="300" border="0" /></a>
<div class="piefoto_esto">Un tubo de 12 pulgadas al lado de la Vialidad Sacramento que provocó el corte del servicio durante toda la mañana y hasta alrededor de las cuatro de la tarde. Foto: El Heraldo de Chihuahua</div>
<div class="cabezaprincesto"><a href='notas/n1092329.htm' class='cabezaprincesto' >Sin agua 8 mil usuarios</a></div>
<div class="resumenesto"><a href='notas/n1092329.htm' class='resumenesto' >La ruptura de una línea en el tanque de rebombeo de agua Sacramento dejó sin servicio a ocho mil usuarios, en once colonias del sur de la ciudad. </a></div>
</div>
</div>
</div>
I've want to get the picture (with or without caption) and then the title of the article. These 3 things I can get by using:
//div[@class='fondoprincipal'] <-- gives me the main image and caption
//a[@class='cabezaprincesto']/text() <-- gives me the article's title
but I can't get ahold of the small description which is the div with class="resumenesto", I haven't tried getting anything by that id because the same id is used over and over through the rest of the HTML so it returns lots of extra items.
How can I get this particular one? and then would any of you recommend me a good way of parsing it to another webpage? I was thinking maybe php writing some html using those values but I'm not sure really...
Edit
What I mean by "this particular one" is how do I get this div class="resumenesto", the one residing within div class="fondoprincipal"...
Edit 2
Thank you, now xPath Traversing is a little bit more clear. But then about my second question, would any of you recommend me a good way of parsing it to another webpage? I was thinking maybe php writing some html using those values but I'm not sure really..