TY_BCA_AWT_SLIP 23_1



23.    Write a PHP script to generate an XML in the following format
HTML file
<html>
<head>

<title>Create XML</title>
</head>
<form action=slip23.php.php method=get>
Enter Book Title<input type=text name=txtTitle></br>
Enter Publication<input type=text name=publ></br>
<input type=submit value="submit">
</form>
</html>

PHP File
<?php

echo "Links data posted";
$ele=$_GET['txtTitle'];
$att=$_GET['publ'];
$xmltags="<?xml version=1.0?>";
$xmltags=$xmltags."<Bookstore>";
$xmltags=$xmltags."<Books>";
$xmltags=$xmltags."<PHP>";
$xmltags=$xmltags."<title>";
$xmltags=$xmltags.$ele;
$xmltags=$xmltags."</title>";
$xmltags=$xmltags."<publication>";
$xmltags=$xmltags.$att;
$xmltags=$xmltags."</attrib>";
$xmltags=$xmltags."</PHP>";
$xmltags=$xmltags."</Books>";
$xmltags=$xmltags."</Bookstore>";

if($fp=fopen("books.xml","w"))
{
            if($wt=fwrite($fp,$xmltags))
            {
              echo "File created";
            }
            else
              echo "Not write";
}
else
echo "Not opened";

?>

No comments:

Post a Comment

Note: only a member of this blog may post a comment.