Reputation: 97
Hi I have to parse an XML file in android but there aren't root element in Xml. Like that below:
<?xml version="1.0" encoding="UTF-8"?>
<iii>
<kkk>test</kkk>
<ppp>000</ppp>
</iii>
<iii>
<kkk>test</kkk>
<ppp>000</ppp>
</iii>
<iii>
<kkk>test</kkk>
<ppp>000</ppp>
</iii>
..
Is it possible to parse without root element ? Thank you.
Upvotes: 1
Views: 653
Reputation: 33511
First, this is not valid XML, so no parser will accept this. If you can fix the generating part of the application, do that.
The simplest way to fix it if you cannot do anything about the document generator, is to give it a root element. Just put <root>
just after the <?xml>
and </root>
at the end of the document. Then feed that to your XML parser.
Upvotes: 1