Android: XML parsing: org.w3c.dom.DOMException: Only one root element allowed

穿精又带淫゛_ 提交于 2019-12-24 03:22:35

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!