Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

< and > in java string  RSS feed

 
Ambika Jain
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I want to save xml in java string. For example <data>100</data>.
When I save this I get <data>100</data>
what should I do to save it with < and > brackets.

Thanks !
 
Olivier Houyoux
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

You could use the simple Java-based JDOM library (http://www.jdom.org) for manipulating XML.
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16028
87
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't understand your question.

The characters < and > are not special characters in Java strings, so what's the problem?
 
Ambika Jain
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
my problem is that, the xml is getting saved as

<Data>100</Data> instead of <Data>100</Data>

Thanks,
 
Ambika Jain
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What I mean is :
& l t ; Data & g t ;

when I post this reply, I get it converted to < and >
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16028
87
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How are you saving the data? Java does not automatically escape < and > into & l t ; and & g t ;
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!