I'm trying to read an XML file with PHP but I'm only getting the first result and can't figure out why.
XML structure:
<main>
<data>
<record>
<column name="title">Some title here</column>
</record>
<record>
<column name="title">Some second title here</column>
</record>
</data>
</main>
Pretty basic. This is the code I'm using to getting the results:
foreach($XML->data->record as $product) {
$title = mysql_real_escape_string($product->title);
}
But this only gives an empty string so I guess I'm looking at the wrong path. The code below does work, but only gives me the first record and not the other records in the XML file.
foreach($XML->data as $product) {
$title = mysql_real_escape_string($product->record->title);
}
The answer is probably easy, but I can't figure it out. Hope someone is willing to help :)