S
SM
Can't get this small piece of code to work? Need help
I have a XML that looks like this:
<?xml version="1.0" encoding="utf-8"?>
<VIDEO>
<item>
<title>Letters</title>
<videos>
<title>a</title>
<title>b</title>
<title>c</title>
</videos>
</item>
<item>
<title>Numbers</title>
<videos>
<title>1</title>
<title>2</title>
<title>3</title>
</videos>
</item>
</VIDEO>
$file = 'db.xml';
$xml = @simplexml_load_file($file);
foreach($xml->item as $item) {
echo 'Letters ' . $item->title;
foreach($item->videos as $vid) {
echo $vid->title;
}
}
Output: LettersaNumbers1
It should be: LettersabcNumbers123
What's wrong?
Thanks
Marco
I have a XML that looks like this:
<?xml version="1.0" encoding="utf-8"?>
<VIDEO>
<item>
<title>Letters</title>
<videos>
<title>a</title>
<title>b</title>
<title>c</title>
</videos>
</item>
<item>
<title>Numbers</title>
<videos>
<title>1</title>
<title>2</title>
<title>3</title>
</videos>
</item>
</VIDEO>
$file = 'db.xml';
$xml = @simplexml_load_file($file);
foreach($xml->item as $item) {
echo 'Letters ' . $item->title;
foreach($item->videos as $vid) {
echo $vid->title;
}
}
Output: LettersaNumbers1
It should be: LettersabcNumbers123
What's wrong?
Thanks
Marco