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 version

    hmm... strangely, compare DOM Functions with DOM XML Functions.

    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 this

        It 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.

            5 months later

            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...

              4 months later

              It's not the Wamp server; it's your php.ini which most likely loads the php_domxml.dll. PHP5 comes default with the DOM extention enabled. php_domxml is for PHP4 and should be commented.

                That was the problem, the solution i found in another forum. Commented the line php_domxml.dll and now is ok.
                🙂

                  Write a Reply...