The first method:
Copy the code The code is as follows:
header("Content-type: text/xml");
echo "";
echo "
";
echo "";
echo "";
echo "Little Rookie";
echo "" ;
echo "";
echo "24";
echo "";
echo "";
echo "Male" ;
echo "";
echo "";
echo "";
echo "";
echo "Yanyan";
echo "";
echo "";
echo "23";
echo "";
echo "";
echo "female";
echo "";
echo "";
echo " users>";
?>
Second method:
Copy code The code is as follows:
header("Content-type: text/xml");
echo "";
echo "
Little Rookie24 MaleYanyan23Female ";
?>
Third method:
Copy code The code is as follows:
/*
Use PHP’s DOM control to create XML output
Set the output content type to xml
* /
header('Content-Type: text/xml;');
//Create a new xml file
$dom = new DOMDocument('1.0', 'utf-8');
//Create element
$response = $dom->createElement('response');
$dom->appendChild($response);
//Create the element and make it a child element of
$books = $dom->createElement('books');
$response->appendChild( $books);
//Create a title for the book
$title = $dom->createElement('title');
$titleText = $dom->createTextNode('PHP and AJAX');
$title->appendChild($titleText);
//Create isbn element for book
$isbn = $dom->createElement('isbn');
$isbnText = $dom->createTextNode('1-21258986');
$isbn->appendChild($isbnText);
//Create book element
$book = $dom->createElement('book');
$book->appendChild($title);
$book->appendChild( $isbn);
//Regard as child element
$books->appendChild($book);
//Create an XML structure in a string variable
$xmlString = $dom->saveXML();
//Output XML string
echo $xmlString;
?>
http://www.bkjia.com/PHPjc/327454.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/327454.htmlTechArticleFirst method: Copy the code as follows: ?php header("Content-type: text/xml") ; echo "?xml version=/"1.0/" encoding=/"UTF-8/"?"; echo "users"; echo "user"; echo "name"; echo "小...