Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Conversion of non serializable object to XML

 
chetan dhumane
Ranch Hand
Posts: 641
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to convert non serialized object in to XML ?
 
Peter Taucher
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You take all the attributes and place them in a defined DOM tree. But I'm not really sure what you're asking -> TellTheDetails
 
chetan dhumane
Ranch Hand
Posts: 641
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Spannable object in the android contains all the properties of the text like bold , italic and even more.
I want to store those properties in the file , to read it later.
Spannable is not serializable , even if you type cast it to CharSequence you cant store it.
 
Rob Spoor
Sheriff
Pie
Posts: 20751
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
perhaps XStream is an option.
 
chetan dhumane
Ranch Hand
Posts: 641
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Prime wrote:perhaps XStream is an option.

I have tried XStream too.

Xstream is not able to convert it into the xml file.
 
Peter Taucher
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Spannable is an interface, not a class. I think you want to serialize objects of a class that implement this interface (like SpannableString). So is there any hint on why XStream would not work? Again -> TellTheDetails
 
Lester Burnham
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have asked this question is so many variants by now that one would assume you'd have checked out the Android source code by now.
 
chetan dhumane
Ranch Hand
Posts: 641
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Peter Taucher wrote:Spannable is an interface, not a class. I think you want to serialize objects of a class that implement this interface (like SpannableString). So is there any hint on why XStream would not work? Again -> TellTheDetails


Yeah Spannable is interface.But even SpannableString or SpannableStringBuilders are also not serializable.
XStream only works when you have the normal text like CharSequence = "abcd"

But if you perform the following operations then it will not work.
Spannable str (Assume there are some text properties in the this string)
CharSequence chr = (CharSequence)str;

xStream.toXML(chr)

But if you do like this it will work
CharSequence chr = "Simple string"
xStream.toXML(chr)
Because it is a normal charsequence without the text formatting properties.

Do you want anymore information , let me know.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic