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

Discussion in 'XML' started by SM, Jun 3, 2008.

  1. SM

    SM Guest

    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
     
    SM, Jun 3, 2008
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Moritz Beller
    Replies:
    19
    Views:
    689
    Pete Becker
    Jun 4, 2004
  2. Replies:
    6
    Views:
    424
    Keith Thompson
    May 17, 2006
  3. Patrick Plattes

    Download a file piece by piece

    Patrick Plattes, Nov 30, 2006, in forum: Ruby
    Replies:
    2
    Views:
    211
    Patrick Plattes
    Nov 30, 2006
  4. Gaba Luschi

    question about a small piece of code

    Gaba Luschi, Feb 20, 2011, in forum: Ruby
    Replies:
    2
    Views:
    110
    masdel
    Feb 20, 2011
  5. SM
    Replies:
    2
    Views:
    184
Loading...

Share This Page