I have like this XML in String
<?xml version='1.0' encoding='UTF-8'?><errors><error><domain>yt:quota</domain><code>too_many_recent_calls</code></error></errors>
This XML is not in file. It is in String then how i can parse it?
Regards, Girish
I have like this XML in String
<?xml version='1.0' encoding='UTF-8'?><errors><error><domain>yt:quota</domain><code>too_many_recent_calls</code></error></errors>
This XML is not in file. It is in String then how i can parse it?
Regards, Girish
You can use the SAXParser of Android to parse this String. The InputSource you need for the XMLReader of the Parser expects an input stream, so you have to convert your String into an input stream. You can use a ByteArrayInputStream for this:
InputStream is = new ByteArrayInputStream( myString.getBytes( charset ) );
See also: How do I turn a String into a InputStreamReader in java?
http://developer.android.com/reference/javax/xml/parsers/SAXParser.html
convert your string to an InputStream using ByteArrayInputStream:
String xml ="valid xml here";
InputStream is = new ByteArrayInputStream(xml.getBytes("UTF-8"));
dom = builder.parse(is);
Or
Check below link