Welcome Guest, Not a member yet? Register   Sign In
[PHP DOM] get all span elements inside a specific element
#1

[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 Smile.

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) {
  echo $data->nodeValue;
}

How do I make sure I only get the spans inside table_id?


Messages In This Thread
[PHP DOM] get all span elements inside a specific element - by El Forum - 11-05-2010, 05:20 PM



Theme © iAndrew 2016 - Forum software by © MyBB