Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Special Characters

 
Rajkumar Katudia
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to extract data from HTML file and write it to XML file.

Everything is fine, just that special characters are creating an issue.

< and > get converted to & lt; and & gt;

However, I expect < and > instead of & lt; and & gt;

Please help me resolve this.

THE CODE:
 
Rajkumar Katudia
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The issue is with the tag where I try to create CDATA.

The < and > get converted to & lt; and & gt;

Please suggest how do I convert them back to < >
 
Rob Spoor
Sheriff
Pie
Posts: 20669
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
String.replace?
 
Rajkumar Katudia
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Prime wrote:String.replace?


You mean String.replace("& gt;",">");

???
 
Rajkumar Katudia
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess my question is not quite clear. I'll try and re-frame it.

Here's what I am trying to do:
I am trying to write an XML doc with the code present in First post.
I am creating Elements and then setting text for each element.
The text for one of the elements has tags. Basically HTML content.

So the tag with the content should look like this:
<body>
<br>
<br>
Some text sample text dummy text. Trial Text. ahkjsj Text
<p>
dsfsdf jkkjs kifsdfko kmlsmdkfmiusdfyugsd y deser cybvubu ij njnknmlkm
<table>
<tr>
<td>
Column 1
</td>
<td>
Column 2
</td>
<td>
Column 3
</td>
</tr>
</table>
</body>


However

The code outputs the content as:

<body>
& lt;br& gt;
& lt;br& gt;
Some text sample text dummy text. Trial Text. ahkjsj Text
& lt;p& gt;
dsfsdf jkkjs kifsdfko kmlsmdkfmiusdfyugsd y deser cybvubu ij njnknmlkm
& lt;table& gt;
& lt;tr& gt;
& lt;td& gt;
Column 1
& lt;/td& gt;
& lt;td& gt;
Column 2
& lt;/td& gt;
& lt;td& gt;
Column 3
& lt;/td& gt;
& lt;/tr& gt;
& lt;/table& gt;
</body>

Now, after I create the XML, I parse it again to extract data and put it into a HTML. Now, Since the < and > tags have been replaced by & lt; and & gt;, The parser fails.

So, I need a way to instruct the method at Line 117 (message 1), not to replace the < and > with & lt; and & gt;.

How do I do this?

Please help.

Thanks in advance.

Raju katudia.
 
Rajkumar Katudia
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please help me how do I do this???
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic