spannablestring - comparing two spanned strings in edittext in android -


i having strange problem in app. have edittext getting user input text. enabling user add formatting (bold/italic etc) entered string. store string json string. further on in flow in app, display same json string edittext. compare displayed string in edittext 1 stored in json string. here how 2 strings differ

string 1: <p dir="ltr"><i><b>test</b></i></p>

string 2: <p dir="ltr"><b><i>test</i></b></p>

as can see above, strings different sequence of tags different. though actully same string same formatting. hence comparision of these 2 strings fails, causing issues in app.

methods use string 1:

testjson.put("my text", html.tohtml(trimspannable(new spannablestringbuilder(myedittext.gettext()));

then use below code display json edittext

myotheredittext.settext(trimspannable((spannablestringbuilder)(html.fromhtml(testjson.getstring("my text"))));

for string 2:

string2 = html.tohtml(new spannablestring(myedittext.gettext()));

any suggestions has here help. thanks.