• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Special Characters

 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 < >
 
Sheriff
Posts: 22822
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
String.replace?
 
Rajkumar Katudia
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please help me how do I do this???
 
Put the moon back where you found it! We need it for tides and poetry and stuff. Like this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic