dom - Can't get Xpath to only output some TD's -


it's easy if know how, don't, , after spending hours googling have ask "real" programmers, i'm not one.

i can't seem find tutorial or code example that'll work me. let's wanted output "eurodiesel 10" tr (scroll halfway down find it) , want data td number 1 , 9. how go doing that?

i want add output data sql db date stamp update once day. assume can done cron job, correct , should make job each price list want harvest data or in single script (the sites different)?

first of need correct data. got far.

<?php  $dom = new domdocument; $date = date("j. f, y"); libxml_use_internal_errors(true); $dom->loadhtmlfile('http://www3.statoil.com/mar/kbh00438.nsf/unid/8c81e46a6ec8ba3bc12578c0002fff5a?opendocument'); libxml_use_internal_errors(false); $xpath = new domxpath($dom); $atag = $xpath->query('//p[@class="text"]');  foreach($atag $val) {     echo $date, '', $val->plaintext. "". utf8_decode(trim($val->nodevalue, "")) . "<br />\n"; } ?> 

i hope guys can me out, learning here...

thanks! art

as xpath, think /html/body/form/table/tbody/tr[normalize-space(td[1]) = 'eurodiesel 10']/td[position() = 1 or position() = 9] should do. access $val->textcontent instead of nodevalue.


Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

c# - SharpSVN - How to get the previous revision? -

php cli reading files and how to fix it? -