?
Solved

Handeling <LI> from the database

Posted on 2004-04-15
12
Medium Priority
?
312 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

In this modest contribution, I want to share with the IT community (especially system administrators, IT Support Engineers and IT Help Desks) about Windows crashes/hangs and how to deal with these particular problems.
If you're a modern-day technology professional, you may be wondering if certifications are really necessary. They are. Here's why.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

800 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