Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Feb 2007
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question using php variables as XML node attributes

    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

  • #2
    New Coder
    Join Date
    Jul 2006
    Posts
    44
    Thanks
    0
    Thanked 0 Times in 0 Posts
    try something like this
    PHP Code:
    <person firstname="<?=$rows['firstname'];?>"/>"

  • #3
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    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.
    Last edited by Fou-Lu; 02-25-2007 at 03:24 AM.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •