468,247 Members | 1,262 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,247 developers. It's quick & easy.

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

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
Jun 27 '08 #1
0 996

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

12 posts views Thread by Randy Webb | last post: by
47 posts views Thread by Mountain Bikn' Guy | last post: by
1 post views Thread by Nobody | last post: by
48 posts views Thread by Ward Bekker | last post: by
10 posts views Thread by est | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by kermitthefrogpy | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.