...

View Full Version : using php variables as XML node attributes



kapil1312
02-24-2007, 07:27 AM
hi

I am new to php.

I am fetching firstname from table ....

$sql="SELECT * FROM table";
$result=mysql_query($sql);

while($rows=mysql_fetch_array($result)){
$rows['firstname'];

Now I want to create XML and use $rows['firstname']; as an attribute

header('Content-Type:text/xml');
"<person firstname=" $print_latitude />" //Its not working.

Can anybody help me to do this ?

Thanks

martialtiger
02-24-2007, 05:20 PM
try something like this


<person firstname="<?=$rows['firstname'];?>"/>"

Fou-Lu
02-25-2007, 03:22 AM
Try using the DOM/DOMXML functions related through php. Best of my knowledge, the vars are parsed by php during the runtime on the xml code.

[EDIT]
Thought I would mention this as well, be careful when using xml through php. Attempting to parse an xml file with shortags enables causes a fatal exception, as the <?xml attempts to parse as php. Just watch for it. If you get it, you simply throw it in a non-parsable string.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum