0

I just found a bug for my APP, which is run normally in Android 4.0 , but will crash in Android 2.3 , I trace it and found the problem is decode XML files

the XML files format is

<a>
 <b></b>
</a>
<a>
 <b></b>
</a>

it is fine when I use PULL in Android 4.0 ,but in Android 2.3 , I found out that the format has to be :

*<AAA>
 <a>
   <b></b>
 </a>
 <a>
   <b></b>
 </a>
</AAA>*

it means that the XML must be a tree in Android 2.3 then we could use PULL , otherwise it will crash ?

So is there any document from Google to prove that ? I'm looking for that .

Thanks a lot !

Bruce_Van
  • 46
  • 5

1 Answers1

1

I am pretty sure that all properly formed XML documents require a root element (AAA in your case). Obviously, some parsers may have the ability to suppress this error and just read as per normal, such as the parser present in Android 4.0. Please see this Wikipedia page with regards to XML root elements.

EDIT: Google Document

Please find the Google document that links directly to an XML specifications sheet (It's the "See Also" document/link).

JosephGarrone
  • 4,081
  • 3
  • 38
  • 61
  • It seems XML don't have to have a root element in Android 4.0, PULL runs fine in that~ And Sax seems could handle that problem . Thanks a lot ~~! – Bruce_Van May 27 '13 at 06:53
  • Honestly that sounds like a bug in Android 4.0 to me. A malformed XML file should not be processed as if it were OK. – StilesCrisis May 27 '13 at 06:56
  • Personally, I would prefer a parser that doesn't crash because of a lack of a root element (Maybe it throws a warning to log?), over a parser that just crashes. – JosephGarrone May 27 '13 at 06:58