domdocument.loadxml Error

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

New php-forum User
New php-forum User
Posts: 1
Joined: Sun Dec 30, 2012 8:38 am

domdocument.loadxml Error

Postby billbu450 » Sun Dec 30, 2012 9:06 am

I have spent quite a bit of time trying to find an answer to this but nothing so far. Hopefully someone here can point me in the right direction.

I'm trying to load an XML file into a php DOMDocument object and getting an error even though my xml file appears to be in the expected file location and be valid XML.

I'm getting the error

Warning: DOMDocument::loadXML() [<a href='domdocument.loadxml'>domdocument.loadxml</a>]: Start tag expected, '&lt;' not found in Entity, line: 1 in C:\wamp\www\BmTest01.php on line 3

As seen below Line 3 contains the loadXML() function.

Here is my code.

$doc = new DOMDocument();
echo $doc->saveXML();

I will post my XML file below but first I want to say that the XML file BmTest01.xml is in the wamp root (www) directory as is the php file above. In an attempt to debug, I altered the code to confirm the file exists and I also read the file using readfile(). When viewing the resulting source output from readfile() everything seems to be in order, most notably the opening < as the forst character in the document. I also ran my XML through a validator and my XML showed no errors.

Here is the XML file

<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="styles/BmSQL.xsl"?>
<listentry type="SQL">
<description>Play With SQL - Query Tips and Tricks</description>
<tooltip>Tool Tip for Play With SQL</tooltip>
<listentry type="SQL">
<description>MySQL Home</description>
<tooltip>This is the official home page for MySQL</tooltip>
<listentry type="XML">
<description>W3Schools XML Tutorial</description>
<tooltip>Almost forgot this tool tip</tooltip>
<listentry type="SQL">
<description>MySQL Tutorial</description>
<tooltip>Unofficial but popular MySQL tutorial website</tooltip>

I figured this must be a common problem but I have not been able to find anyting about it anywhere. Any thoughts would be greatly appreciated.

I am running
wampserver 2.2
PHP Version :5.3.13
Windows 7 Home Premium (Ver 6.1 Build 7601 Service Pack 1)
I get the same error on
FireFox 11
Opera 12.12

Return to “PHP coding => General”

Who is online

Users browsing this forum: No registered users and 2 guests