How does php write form data into XML files? How does php write form data into XML files? I am asking for advice. it is best to show the code section !, PHPcoderequire ('config. php'); $ doc = newDOMDocument ('1. 0', & quot; gb2312 & php how to write form data into XML files?
How does php write form data into XML files?
I am asking for advice. it is best to show the code segment!
------ Solution --------------------
PHP code
require('config.php');$doc = new DOMDocument('1.0', "gb2312");$root = $doc->createElement('URL');$root = $doc->appendChild($root);$sql = "select * from cdb_forums";$result = mysql_query($sql);while($row = mysql_fetch_array($result)){ $imgnode = createNode($root, "Image_Information"); createNode($imgnode, "img_link", $row['fid']); createNode($imgnode, "big_image", $row['type']); createNode($imgnode, "thumb_image", $row['status']);}$doc->save("./update.xml");function createNode(&$pNode, $nodeName, $nodeValue='', $nodeAttribute = array()){ global $doc; $node = $doc->createElement($nodeName); if($nodeValue != "") { $nodeText = $doc->createTextNode($nodeValue); $node->appendChild($nodeText); } if(sizeof($nodeAttribute) > 1) { foreach($nodeAttribute as $key=>$value) { $node->setAttribute($key, $value); } } $pNode->appendChild($node); return $node;}