View Full Version : using php variables as XML node attributes

02-24-2007, 07:27 AM

I am new to php.

I am fetching firstname from table ....

$sql="SELECT * FROM table";


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

"<person firstname=" $print_latitude />" //Its not working.

Can anybody help me to do this ?


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

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

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.

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