Can't get this small piece of code to work? Need help

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,733
Messages
2,569,440
Members
44,830
Latest member
ZADIva7383

Latest Threads

Top