Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Mar 2006
    Posts
    66
    Thanks
    3
    Thanked 0 Times in 0 Posts

    DOMDocument Problem

    Hi,

    I am following a tutorial from a an Ajax/PHP book. I have written a script the generates an xml document. I keep getting the following error when I try to open the script in a browser (even when I download the code from the support site):

    XML Parsing Error: junk after document element
    Location: http://hapuk.coreware.co.uk/test/aj...php/phptest.php
    Line Number 2, Column 1:<b>Warning</b>: domdocument() expects at least 1 parameter, 0 given in <b>/home/chris/happenin/test/ajax/foundations/php/phptest.php</b> on line <b>5</b><br />
    ^

    ie6 says:

    The XML page cannot be displayed
    Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.


    --------------------------------------------------------------------------------

    Only one top level element is allowed in an XML document. Error processing resource 'http://hapuk.coreware.co.uk/test/ajax/...

    <b>Warning</b>: domdocument() expects at least 1 parameter, 0 given in <b>/home/chris/happenin/test/ajax/...


    The code that is causing the error is:

    // set the output content type as xml
    header('Content-Type: text/xml');
    // create the new XML document
    $dom = new DOMDocument();

    I'm assuming that there must be something wrong with the php installation on the server. Anybody got any ideas?
    Chris Holbrook
    Freelance Designer and Musician
    Freelance Web Designer and Musician: Bristol, UK
    Visit my site: http://www.chrisholbrook.com

  • #2
    Senior Coder
    Join Date
    Sep 2005
    Posts
    1,791
    Thanks
    5
    Thanked 36 Times in 35 Posts
    which version of PHP are you using? with 5.1.6 I get no error, but google seems to suggest there might be problems with previous versions, particualrly with regards to the DOM and DOMXML extensions (the latter of which is deprecated) not playing nicely with one another.

  • #3
    New Coder
    Join Date
    Mar 2006
    Posts
    66
    Thanks
    3
    Thanked 0 Times in 0 Posts
    PHP Version 4.4.0

    Build Date Apr 12 2006 15:16:56

    What do you suggest I do?

    Thanks a lot
    Chris Holbrook
    Freelance Designer and Musician
    Freelance Web Designer and Musician: Bristol, UK
    Visit my site: http://www.chrisholbrook.com

  • #4
    ess
    ess is offline
    Regular Coder
    Join Date
    Oct 2006
    Location
    United Kingdom
    Posts
    865
    Thanks
    7
    Thanked 29 Times in 28 Posts
    I am not sure if this is a PHP version problem or not. It could well be something to do with your php.ini configuration, or it could well be something else.

    To solve this problem the easy way, I would suggest that you install an already packaged configuration of PHP, Apache2, and MySql.

    If you are working on a Windows machine, you download and install WAMP , which comes bundled with PHP5, Apache2, MySQL5, PhpMyAdmin, SQLite, SQLiteAdmin.

    I have this running on local machine when I am developing websites and it works like a charm. You can also download PHP4 add-on, which will allows you to switch between PHP4 and PHP5 when developing websites. Can be very handy when developing websites for a specific server.

    If you are working on Linux/Mac machine, I suggest you download and install Apache Friends . There are lot of add-ons there as well. such as Tomcat Mod_JK module, which allows you to configure Apache and Tomcat to work together.

    I hope that helps.

    All the best

  • #5
    New Coder
    Join Date
    Mar 2006
    Posts
    66
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Thanks a lot for your help. Much appreciated. I have used WAMP locally before. The problem is that I am working on a rented server and the owners are notoriously unresponsive. I just wanted to see if there was a workaround before I approached them. I'm assuming that the suggested solutions all require full access to the server which I don't have. Nevermind. Thanks again for your help
    Chris Holbrook
    Freelance Designer and Musician
    Freelance Web Designer and Musician: Bristol, UK
    Visit my site: http://www.chrisholbrook.com


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •