Processing unorder lists PHP-HTML -
good afternoon.
i have page looks -edit- important note code dynamic. users uploading these pictures, through echo, new list object created img code inside. cannot "hard code" because lists never same. have clients uploading 50+ pictures, have 50+ list items. want able fine way turn list create string - or open other suggestions.
<ul> <li class="ui-state-default"><img code img 1></li> <li class="ui-state-default"><img code 2></li> <li class="ui-state-default"><img code 3></li> <li class="ui-state-default"><img code 4></li> <li class="ui-state-default"><img code 5></li> <li class="ui-state-default"><img code 6></li> <li class="ui-state-default"><img code 7></li> </ul> what find way process list in correct order through php.
i.e create xml list.
i familiar simplexml, having hard time figuring out php see list. question how - how can php read list, can create xml of it?
i have tried several ajax examples, ajax complicated when examples i've seen.
thank assistance can provide, please not leave comments saying "use dom" , not explaining further. ive had way many of those.
edit ------------
my last attempt this
<?php $dom = new domdocument(); $dom->loadhtml($data); $unorderedlist = $dom->getelementsbytagname('ul'); foreach ($unorderedlist->item(0)->getelementsbytagname('li') $unorderedlist) { echo $unorderedlist->nodevalue.'<br />'; } ?> but, unable php able see list...my question revolves around how php see list in html above (same page) not how create xml.
you looping on <li> elements looking image tags. need go level deeper
if ($unorderedlist->haschildnodes()) { foreach ($unorderedlist->childnodes $image) { var_dump($image->getattribute('src')); } }
Comments
Post a Comment