Hi..
I m rapraj...! I want to write into xml file.
Suppose myxml file is:
//********************* newspost.xml ********************
<?
$xmlstr = "<?xml version='1.0' standalone='yes'?>
<!DOCTYPE chapter SYSTEM '/share/sgml/Norman_Walsh/db3xml10/db3xml10.dtd'
[ <!ENTITY sp \"spanish\">]>
<IEEE ID='findme' language='&sp;'>
<tbody>
<id>1</id>
<name>raj</name>
<email>
[email protected]</email>
<title>India Vs Pakistan Cricket match</title>
<description>India Vs Pakistan cricket match will in Kanpur on Nov11 2007</description>
</tbody>
//I want to write next contents here
</IEEE>";
?>
//************************************************** ****
//Code for writing my next content before closing </IEEE> tag
//************************************************** ******
include("passwordfile/newspost.xml");
if (!$dom = domxml_open_mem($xmlstr))
{
echo "Error while parsing the document\n";
exit;
}
$elements = $dom->get_elements_by_tagname("tbody");
//print_r($elements);
$element = $elements[0];
$parent = $element->parent_node();
$newnode = $parent->append_child($element);
$children = $newnode->children();
$children = $newnode->newcontent();
$attr = $children[1]->set_attribute("align", "left");
$xmlfile = $dom->dump_mem();
echo htmlentities($xmlfile);
?>
The above code is displaying very well I made the changes as below, to get the new contents field up by any user through GUI :
//************************************************** ***********
include("passwordfile/newspost.xml");
function newcontent()
{
$newcont="<tbody>\r\n<id>".$id."</id>\r\n<name>".$name."</name>\r\n<email>".$email."</email>\r\n<newstitle>".$newstitl
e."</newstitle>\r\n<description>".$description."</description>\r\n</tbody>";
//$args=$newcont;
return $newcont;
}
if (!$dom = domxml_open_mem($xmlstr))
{
echo "Error while parsing the document\n";
exit;
}
$news="<tbody>\r\n<id>".$id."</id>\r\n<name>".$name."</name>\r\n<email>".$email."</email>\r\n<newstitle>".$newstitle."
</newstitle>\r\n<description>".$description."</description>\r\n</tbody>";
$elements = $dom->get_elements_by_tagname("tbody");
//print_r($elements);
$element = $elements[0];
$parent = $element->parent_node();
//$newnode = $parent->append_child($element);
$newnode = $parent->append_child($news);
//$children = $newnode->children();
$children = $newnode->newcontent();
$attr = $children[1]->set_attribute("align", "left");
$xmlfile = $dom->dump_mem();
echo htmlentities($xmlfile);
?>
//********** THE ERROR ARE
Warning: append_child() expects parameter 1 to be object, string given in /var/www/html/ieee/raajappend.php on line 44
Fatal error: Call to a member function on a non-object in /var/www/html/ieee/raajappend.php on line 46
So please suggest me for the exact output
Thanx in advance..