[RESOLVED] PHP DOM METHODS

liunx

Guest
Hai,
I am trying to use DOM methods
dom->createElement
dom->createTextNode etc...
But i am getting these methods are not avilable. Instead of
the method names are changed like
dom->create_Element
dom->create_Text_Node
etc...

can anyone tell me these methods are deprecated , where i can get new methods details.

I am using php5.2.4 versionhmm... strangely, compare DOM Functions (<!-- m --><a class="postlink" href="http://www.php.net/manual/en/ref.dom.php">http://www.php.net/manual/en/ref.dom.php</a><!-- m -->) with DOM XML Functions (<!-- m --><a class="postlink" href="http://www.php.net/manual/en/ref.domxml.php">http://www.php.net/manual/en/ref.domxml.php</a><!-- m -->).

The DOM Functions API use names such as createElement, but the DOM XML Functions API use names such as create_attribute. As such, it looks like you have the DOM XML Functions available on PHP5, but the DOM Functions are not available. A rather unusual combination, based on what the PHP Manual says. Ask your host about it.I understand In my system DOM XML functions are enabled.
But DOM functions are enabled default. but' it's not working.
I am using WAMP server package.
i ran following code it's giving error

$article = $don->appendChild($don->createElement("article"));
$article_name = $article->appendChild($don->createElement("article_name"));
$article_text = $article_name->appendChild($don->createTextNode('News & Sports'));

$author_name = $article->appendChild($don->createElement("author_name"));
$author_text = $author_name->appendChild($don->createTextNode('Bala'));

$article_category = $article->appendChild($don->createElement("category"));
$ctext = $article_category->appendChild($don->createTextNode('sports'));

$article_date = $article->appendChild($don->createElement("article_date"));
$ttext = $article_date->appendChild($don->createTextNode(date('y-m-d')));
$tes = $don->save('article.xml');



Warning: domdocument::domdocument() expects parameter 2 to be long, string given in D:\wamp\www\fmmo\dom.php on line 3

Fatal error: Call to undefined method domdocument::appendChild() in D:\wamp\www\fmmo\dom

can you tell me how to solve thisIt looks like the DomDocument methods are not available because you haven't got a DomDocument. Read the first error message.

Warning: domdocument::domdocument() expects parameter 2 to be long, string given in D:\wamp\www\fmmo\dom.php on line 3

Let's see what you're doing there, because that is where things start going wrong. If the constructor fails then the object doesn't get constructed.

The DomDocument constructor does expect the second parameter to be a string, so that's odd, but if you've got PHP4's DOM XML package floating around as well it's a guess that the two won't work together. Have you asked your host what the setup actually is?Hi,
I don't know why this happen ? i re installed PHP again , Now Dom functions are working.
Thanks for your help.The same problem using Wamp server, version 1.7.3 - not the PHP, because my PHP version is 5.2.4

The bug caused by this line:
$dom = new DOMDocument( '1.0', 'iso-8859-1' );

outputs: "Warning: domdocument::domdocument() expects parameter 2 to be long, string given in..."

But, testing the same script using my server on Ubuntu 7.10, no bug ocurred.

Why? i don't know. Searching all references in Google, NOBODY knows the solution.

The solution is: install another server, or download the PHP and Apache separated and install one by one...
 
Back
Top