I am very beginner to PHP
. I want to create an XML
file dynamically and i know how to do that. But here in this case, in the XML
file, one node should contain an attribute "name" with a value from $_POST
variable. How to write PHP
code for creating XML
file which contain a node with attribute "name".
问问题
1246 次
2 回答
0
As a solution to your problem please try executing following example code snippet
The below code snippet is created on basis of assumption that there is a form for user registration containing fields such as email ,address depicting the procedure for dynamically generation of **xml** content using php
<?php
$xmlstring='<xml>';
if($_SERVER['REQUEST_METHOD']=='POST')
{
$xmlstring.='<user>
<email>'.$POST['email'].'</email>
<address>'.$_POST['address'].'</address>
</user>';
}
$xmlstring.='</xml>';
header('Content-type:text/xml');
echo $xmlstring;
die;
?>
于 2013-04-26T05:11:10.260 回答
0
它可能对您有帮助:
<?php
// Send the headers
header('Content-type: text/xml');
header('Pragma: public');
header('Cache-control: private');
header('Expires: -1');
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
echo '<xml>';
// echo some dynamically generated content here
echo '</xml>';
?>
最后保存带有.php
扩展名的文件
于 2013-04-26T05:01:34.490 回答