I try to parse xml from str with this methods:
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
InputSource is = new InputSource();
is.setCharacterStream(new StringReader(str.toString()));
Document doc = db.parse(is);
and in str i have :
<foo><bar>baz</bar></foo>
but always in db.parse(is); the app is crash.
but if i put instead :
is.setCharacterStream(new StringReader(str.toString()));
this:
is.setCharacterStream(new StringReader("<foo><bar>baz</bar></foo>"));
it work perfect. any idea?
I did not know what is
str.If str is already a string then not need to usestr.toString.or if str is any TextView or EditText then use str.getText().toString.Then it will work.And if you have third case in spite of these two then please specify this so that i could edit my answer