• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

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: 22656
126
Eclipse IDE Spring VI Editor 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???
 
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic