Jump to content

XML parse error


BeanoEFC

Recommended Posts

Hey Everyone,

 

I have been given an assignment where i am given an XML file and i need to parse it.  The XML is in the following format:

<?xml version="1.0"?> 
<title>Library</title> 
<library>
<book id="1"> 
	<author>J.K.Rowling</author>
	<name>Harry Potter and the Philosopher's Stone</name> 
</book> 
<book id="2"> 
	<author>J.K.Rowling</author>
	<name>Harry Potter and the Chamber of Secrets</name> 
</book>
</library>

 

The problem i have is when i try an parse this XML, with SimpleXML, i get the following error

parser error : Extra content at the end of the document

The source of this error is due to there being no root node.

 

This has left me in a bit of a predicament.  Is there anyway of parsing XML in this format without the root node being added?

 

Regards,

-Ben

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.