PDA

View Full Version : xml loop in javascript


testtest
06-01-2007, 06:04 PM
Hi, for some reason when I try to use <?php echo $xml->content[number_in_loop]; ?> the value I'm getting for the tag is - underfine -. First, let me explain what I'm trying to do. I have some code that will generate a query from a db into an xml file. I also have some javascript code that will take the content and display the text in a fading message. Some of the code is below:


// set name of XML file
$file_one_liners = "some_file_name.xml";

// load file
$xml = simplexml_load_file($file_one_liners) or die ("Unable to load XML file!");



//This loop will only show the first element in the xml file - this works fine
for(i=0;i<fadecontent.length; ++i) {

fadecontent[i]= "<?php echo $xml->content; ?> <?php echo " " . $xml->content->a; ?> ";
}


//Now I want to display all the messages in the xml file - not working - getting - underfine value
for(i=0;i<fadecontent.length; ++i) {

fadecontent[i]= "<?php echo $xml->content[i]; ?> <?php echo " " . $xml->content->a[i]; ?> " ;
}