CodeIgniter Forums

Full Version: Fatal error: Uncaught exception 'DOMException'
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]Prasad.P[/eluser]
Hi everbody,

We are trying to implement a small forum application. In which we use domdocument to store all the user information. We are getting a fatal error in the line marked red, when we happen to execute the following code:

Here is the model:

function ignorecom2($time, $filename)
{
$xmlobj = new DomDocument;
$xmlobj->load('forum/'.$this->session->userdata('stream').'/'.$this->session->userdata('loginname').'/'.$filename.'.xml');
$compost = $xmlobj->getElementsByTagName('commpost');
$comtime = $xmlobj->getElementsByTagName('ctime');
for($i=0 ; $i < $compost->length ; $i++)
{
if($comtime->item($i)->nodeValue === $time)
{
$sample['sample'] = "Inside if condition";
$xmlobj->removeChild($compost->item($i));
}
}
$xmlobj->save('forum/'.$this->session->userdata('stream').'/'.$this->session->userdata('loginname').'/'.$filename.'.xml');
return $sample;
}

Error Message:

Fatal error: Uncaught exception 'DOMException' with message 'Not Found Error' in C:\xampp\htdocs\upgrade_ver\system\application\models\user\forum_model.php:753 Stack trace: #0 C:\xampp\htdocs\upgrade_ver\system\application\models\user\forum_model.php(753): DOMNode->removeChild(Object(DOMElement)) #1 C:\xampp\htdocs\upgrade_ver\system\application\controllers\user\forum_controller.php(171): forum_model->ignorecom2('18:24:27', '1sowjanya') #2 C:\xampp\htdocs\upgrade_ver\system\codeigniter\CodeIgniter.php(224): Forum_controller->ignorecom('18:24:27', '1sowjanya') #3 C:\xampp\htdocs\upgrade_ver\index.php(115): require_once('C:\xampp\htdocs...') #4 {main} thrown in C:\xampp\htdocs\upgrade_ver\system\application\models\user\forum_model.php on line 753


XML file looks like this:

- <root>
- <blog len="2">
- <commpost>
<commname>sample</commname>
<ctime>18:24:27</ctime>
<dd>11</dd>
<mm>06</mm>
<yy>2008</yy>
<comment>bbbbbbbbbbbbbbbb</comment>
</commpost>
- <commpost>
<commname>sample</commname>
<ctime>18:24:32</ctime>
<dd>11</dd>
<mm>06</mm>
<yy>2008</yy>
<comment>vvvvvvvvvvvvvvvvvvvv</comment>
</commpost>
- <post>
&lt;title&gt;aaaaaaaaaa&lt;/title&gt;
<time>18:15:20</time>
<date>11</date>
<month>06</month>
<year>2008</year>
<summary>aaaaaaaaaaaaaaaaaaaa</summary>
</post>
</blog>
</root>