Recently, using the Zendframework framework to do projects, to take the data from the database to generate XML documents. Here's a note about the process:
XML file:
1.
2.
3. Docker JCP1
4. Docker JCP2
5. Docker JCP3
6. Docker JCP4
7. Docker JCP5
8. Docker JCP6
9.
1. Build testcontroller.php and add function.
1. Public Function projectaction () {
1.//xml-related Routine
2.//$list refers to an array of data in the XML.
3. $dom = new DOMDocument (' 1.0 ', ' utf-8 ');
4.//Create root element
5. $root = $dom->createelement ("data");
6. $dom->appendchild ($root);
7.
8.//project name XML List
9. foreach ($list as $project _item) {
//Create child element
$projectname = $dom->createelement (' project ');
$root->appendchild ($projectname);
13.
//Create CDATA section
$cdata = $dom->createcdatasection ($project _item->name);
$projectname->appendchild ($cdata);
17.
$id = $dom->createattribute ("id");
$projectname->appendchild ($id);
20.
//Create attribute value node
$idValue = $dom->createtextnode ($project _item->project_id);
$id->appendchild ($idValue);
24.}
$output = $dom->savexml ();
26.
//Setting up headers and body
$this->_response->setheader (' Content-type ', ' text/xml; Charset=utf-8 ')
->setbody ($output);
$this->_helper->layout->disablelayout ();
31.}
This allows you to output XML on the page.
If you want to save the XML, use $dom->save ("Filename.xml");
This article is from "Bob" blog
http://www.bkjia.com/PHPjc/478702.html www.bkjia.com true http://www.bkjia.com/PHPjc/478702.html techarticle recently, using the Zendframework framework to do projects, to take the data from the database to generate XML documents. Here's a note about the process: XML file: 1. ? xml version=1.0 Encoding=utf-8? 2 .... .