![]() |
[PHP DOM] get all span elements inside a specific element - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: [PHP DOM] get all span elements inside a specific element (/showthread.php?tid=35641) |
[PHP DOM] get all span elements inside a specific element - El Forum - 11-05-2010 [eluser]jant90[/eluser] This is more a general PHP question than a CI one, but it's for an application I'm working on inside the CI framework so I decided I would ask for help on this forum ![]() I'm trying to get all span elements inside a table from a certain HTML page. The table had an unique ID and therefore I can get it as follows: Code: $doc->getElementById("table_id"); Now I want all spans inside that table so I can read the nodeValues, if I wanted to get all of them inside the HTML page I would use: Code: foreach($doc->getElementsByTagName('span') as $data) { How do I make sure I only get the spans inside table_id? [PHP DOM] get all span elements inside a specific element - El Forum - 11-06-2010 [eluser]jant90[/eluser] Wow, I don't see why I didn't got this at first: Code: $doc->getElementById("table_id")->getElementsByTagName('span'); I think I tried this once but made some kind of mistake and thought I didn't work. Oh well, solved! |