How to generate XML file dynamically using PHP?

前端 未结 7 2555
失恋的感觉
失恋的感觉 2020-11-22 00:32

I have to generate a xml file dynamically at runtime. Please help me in generating the below XML file dynamically using PHP.



        
7条回答
  •  我在风中等你
    2020-11-22 00:34

    $query=mysql_query("select * from tablename")or die(mysql_error()); 
    $xml="\n\t\t";
    while($data=mysql_fetch_array($query))
    {
    
        $xml .="\n\t\t";
        $xml .= "".$data['id']."\n\t\t";
        $xml .= "".$data['email_address']."\n\t\t";
        $xml .= "".$data['verify']."\n\t\t";
        $xml .= "".$data['status']."\n\t\t";
        $xml.="\n\t";
    }
    $xml.="\n\r";
    $xmlobj=new SimpleXMLElement($xml);
    $xmlobj->asXML("text.xml");
    

    Its simple just connect with your database it will create test.xml file in your project folder

提交回复
热议问题