Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Handeling <LI> from the database

Posted on 2004-04-15
12
Medium Priority
?
315 Views
Last Modified: 2010-04-01
Hello Expert,
I am getting the body of a story from the database and it looks like this

This is a great story
<li> Testing this story</li>
<li> Testing Two</li>
<li> Testing three </li>

I would like to change everything that is in the <li>Testing this story </li> to dipsplay in my text are as
This is a great story
• Testing this story
• Testing Two
• Testing three
Is there anyway to do this?
Thanks
0
Comment
Question by:jvoros1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 3
  • +1
12 Comments
 
LVL 9

Expert Comment

by:Nick_72
ID: 10834165
I'm not sure I understand...you have this text in a variable, and if you print out that variable in your html, you don't get it formatted?
Can you show how your code looks now?
0
 

Author Comment

by:jvoros1
ID: 10834295
I hope this helps and in the body this is what is stored
This is a great story
<li> Testing this story</li>
<li> Testing Two</li>
<li> Testing three </li>
and i want it to look like
This is a great story
• Testing this story
• Testing Two
• Testing three
Object[] search_results = (Object[])request.getAttribute("search_results");
                  
                  for (int x = 0; x < search_results.length; x++)                            
                  {              
                        HashMap search_result = (HashMap)search_results[x];
                        
                                 String EventID = (String) search_result.get("EventID");
                              String Body =  (String) search_result.get("Body");
                              String Title = URLEncoder.encode(tmpTitle);
                                                 }
<table>
  <tr>
    <td> <textarea rows="19" name="Body" cols="54"><%=Body%></textarea></td>
  </tr>
</table>
Thanks
0
 
LVL 7

Expert Comment

by:searlas
ID: 10834523
A textarea cannot display rendered HTML.  No doubt someone will point you at a few options out there that look like they do, but basically they hide the textarea and use iframes and massive amounts of javascript instead.  for instance:

http://www.interactivetools.com/products/htmlarea/
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 9

Expert Comment

by:Nick_72
ID: 10834529
oh...textarea...I missed that part :)

well, I'm not sure if that is possible. I know another thing that is possible though and could be equally as good, or better. That depends on if the user should be able to edit that text or not. With this example, he/she is not able to do that, but if it's only for presentation - that would suite just fine.

Check this example. It makes a 'fake' textarea which looks as an original, but which allows you to use ordinary html in it:

<HTML>
<head>
<STYLE>
.textAREA {border:3px ridge #dddddd;height:200;width:300;overflow-y:scroll;
border-right:3px double #bbbbbb; border-bottom:3px double #bbbbbb;}

.hiliteON {color:white;background-color:navy;font-family:arial;font-size:10pt}
.hiliteOFF {color:black;background-color:white;font-family:arial;font-size:10pt}
</STYLE>

</HEAD>
<BODY>
<div class="textAREA" style="position:absolute;left:165;top:115">
<li>test 1</li>
<li>test 2</li>
</div>
</BODY>
</HTML>

Hope it helps,

/Nick
0
 
LVL 7

Assisted Solution

by:searlas
searlas earned 500 total points
ID: 10834543
So... to get your 'body' displayed as you want, you shouldn't use a text area at all:
<table>
  <tr>
    <td> <textarea rows="19" name="Body" cols="54"><%=Body%></textarea></td>
  </tr>
</table>

becomes:
<%=Body%>
0
 
LVL 19

Expert Comment

by:Kuldeepchaturvedi
ID: 10834627
try


<td> <textarea rows="19" name="Body" DATAFORMATS="html" cols="54"><%=Body%></textarea></td>
0
 
LVL 19

Expert Comment

by:Kuldeepchaturvedi
ID: 10834643
ooops

it should be

<td> <textarea rows="19" name="Body" DATAFORMATAS="html" cols="54"><%=Body%></textarea></td>


http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/dataformatas_1.asp
0
 

Author Comment

by:jvoros1
ID: 10834656
The user has to be able to edit the text cause this is an update to what they added. SO i am not sure if it will work cause i have more then just that one row i have many rows in my table. And this page is an include in another page? Do you know maybe how i could use a hashcode to do this or a stringtokenizer is that possible some how?
0
 
LVL 19

Assisted Solution

by:Kuldeepchaturvedi
Kuldeepchaturvedi earned 500 total points
ID: 10834739
If all you want to do is to strip off the <LI> and </LI> tag than you can use string tokenizer to separate them..
Hashtable ht=new Hashtable();
int count =0;
StringTokenizer st  = new StringTokenizer(body,"<li>");
while(st.hasMoreElements())
{
String token = st.nextToken();
token = token.subString(0,token.indexOf("</li>");
//put this token where ever you want to..
hastable.put(count,token);
count++;
}

Here I am assuming that all the li tags are in small case....
0
 

Author Comment

by:jvoros1
ID: 10834750
I tried <td> <textarea rows="19" name="Body" DATAFORMATAS="html" cols="54"><%=Body%></textarea></td> too and it still comes up as
<li>       One</li>
 <li>       Two </li>
 <li>       three</li>
:(

0
 
LVL 9

Accepted Solution

by:
Nick_72 earned 1000 total points
ID: 10834757
I don't know how to display that 'dot' in a textarea, but if you can think of showing an asterisk or some other character instead, you could always use the replaceAll() method:

String newBody = Body.replaceAll("<li>", "* ");
newBody = newBody.replaceAll("</li>", "");

/Nick

0
 
LVL 9

Expert Comment

by:Nick_72
ID: 10834846
:)

actually, if you want a new line after every </li> you might want do like this instead:

newBody = newBody.replaceAll("</li>", "\n");

/Nick
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

With the evolution of technology, we have finally reached a point where it is possible to have home automation features like having your thermostat turn up and door lock itself when you leave, as well as a complete home security system. This is a st…
Here in this article, you will get a step by step guidance on how to restore an Exchange database to a recovery database. Get a brief on Recovery Database and how it can be used to restore Exchange database in this section!
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question