Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Can't get this small piece of code to work? Need help

Reply
Thread Tools

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

 
 
SM
Guest
Posts: n/a
 
      06-03-2008
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
question about a small piece of code Gaba Luschi Ruby 2 02-20-2011 06:03 PM
This small piece of code works in Firefox but not in IE 7... why? SM Javascript 2 04-30-2007 01:06 AM
Download a file piece by piece Patrick Plattes Ruby 2 11-30-2006 07:48 PM
Unable to get an output from a piece of code snippet. :Confusing maheshpop1@gmail.com Perl Misc 1 11-02-2006 12:33 PM
Problem with small piece of C code kalyan.listsubs@yahoo.com C Programming 6 05-17-2006 07:43 PM



Advertisments