问题
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.
回答1:
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.
来源:https://stackoverflow.com/questions/11490231/android-xml-parsing-org-w3c-dom-domexception-only-one-root-element-allowed