org.w3c.dom.DOMException: Only one root element allowed in android xml parsing -
i have method in pass xml , returns parsed document.in devices got above shown error.(the xml contains 1 root element actually)
public document getdomelement(string xml) { document doc = null; documentbuilderfactory dbf = documentbuilderfactory.newinstance(); try { documentbuilder db = dbf.newdocumentbuilder(); inputsource = new inputsource(); is.setcharacterstream(new stringreader(xml)); doc = db.parse(is); //i got error here } catch (parserconfigurationexception e) { log.e("error: ", e.getmessage()); return null; } catch (saxexception e) { log.e("error: ", e.getmessage()); return null; } catch (ioexception e) { log.e("error: ", e.getmessage()); return null; } return doc; }
starting of xml this
<?xml version="1.0" encoding="utf-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/commentapi/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" > <channel>
and end
</channel> </rss>
Comments
Post a Comment