Reputation: 622
I am trying to parse an xml file. But i get this error: org.w3c.dom.DOMException: Only one root element allowed at the line:
Document doc = dBuilder.parse(getAssets().open("myfile.xml"));
Please help me solve this.
Thanks in advance.
Upvotes: 2
Views: 6349
Reputation: 674
You must have only one root, it means you must have only once a tag that surround every all tags. For example you can surround all your tags by <root></root>
Also, try to validate your xml file with an xml validator in order to see if your xml is malformed.
Upvotes: 7