php and xml

Is it possible to print the value of an a global variable from a .php page in a .xml page?



is that xml generated by php?

How can I generate a xml with php?

I have this php code:

<? php $database->setQuery("SELECT * FROM #__menu WHERE menutype = 'othermenu' AND published ='1' AND parent = '0' ORDER BY ordering"); $mymenu_rows = $database->loadObjectList(); $mymenu_content = ""; $numero=0; foreach($mymenu_rows as $mymenu_row) { // print_r($mymenu_rows); $mymenulink = $mymenu_row->link; if ($mymenu_row->type != "url") { $mymenulink .= "&Itemid=$mymenu_row->id"; } if ($mymenu_row->type != "separator") { $numero=$numero+1; $mymenu_content .= " } } $mymenu_content = substr($mymenu_content,0,strlen($mymenu_content)-2); ?>

<?php echo $mymenu_content ;?>

to generate a page xml with $mymenu_content like this:

thanks again for your help!

witch global variable do u wanna print?

The global variable that I want to print in a xml document is $mymenu_content

I didn’t write the first line:

<?php global $mymenu_content; ?>

(I’m not sure if I need to declare $mymenu_content like a global variable)

global is only there to be used in functions.
all other vars are global and don’t need to handled in a special way.

Thanks very much for the explanation!
I’m learning to work with php always more…
What can I do to print a variable from a php page in a xml page?

i’m unsure what else u are trying to achieve.

if u try to make it a “real” file take a look at

but i woudn’t do that. just use the php-file.

ur allready doing it.

u should just add header(‘Content-Type: application/xml’) at it’s begining.

Sponsor our Newsletter | Privacy Policy | Terms of Service