Apple’s Worldwide Developers Conference to kick off June 10 at 10 a.m. PDT with Keynote address

The Keynote will be available to stream on apple.com, the Apple Developer app, the Apple TV app, and the Apple YouTube channel. On-demand playback will be available after the conclusion of the stream.

Developer Forums relocated!

Need help with Apple Developer tools and technologies? Want to share information with other developers and Apple engineers? Visit Developer Forums at Apple.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

[iPhone] Can not parse simple XML

Hi!
I have a simple XML

<?xml version="1.0" encoding="utf-8"?><errorCode>2</errorCode><error>Invalid username</error>


and I want to parse it in my app.
First I tried touchXML, but it returned error

Entity: line 1: parser error : Extra content at the end of the document
<?xml version="1.0" encoding="utf-8"?><errorCode>2</errorCode><error>Invalid use
^


Dont know what it means. Googling for that error did not helped.
So I tried NSXMLParser and got error too

Parsing error: Operation could not be completed. (NSXMLParserErrorDomain error 5.)
parsing ended


error number 5 means

NSXMLParserPrematureDocumentEndError
The document ended unexpectedly.


accordinc to docs.
But I really dont understand where is error in such a simple XML! Also W3C online validar told me that XML is valid

docElt: {None}errorCode
No declaration for document root found, validation was lax
The schema(s) used for schema-validation had no errors
No schema-validity problems were found in the target


So where is error in that XML?

BlackBook3,1, Mac OS X (10.5.6), 4Gb ram, 320Gb 7200rpm WD3200BEKT; iPhone 3G 16GB Black

Posted on Mar 1, 2009 1:21 AM

Reply
Question marked as Best reply

Posted on Mar 1, 2009 2:39 AM

In a XML document it is only allowed to have a single root element. In your case the will be "the document" and everything afterward (not xml comments) is not allowed.
2 replies

[iPhone] Can not parse simple XML

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.