Please help in formatting HTML..

Topics: Developer Forum, User Forum
Aug 7, 2009 at 6:13 AM

My site is about to go live and I have some big issue with content maneged pages.. Please help

I have lot of articles in the database and while showing it in the site I replace the newline chracter with <br /> using following code...

string article = details.Replace(System.Environment.Newline, "<br />");

But its making issues if my articles have tables or lists in the content.. The above code will put <br /> after each tags of the table.. so I will have <br /> between all the <tr>, <td>, <tbody> etc.. resulting in a malformed HTML and its making lot of issues while display..

I want to replace only the new lines in content not between the tags..

URGENT help pleaes.. this is the only issue to be solved for me to go live

Aug 7, 2009 at 6:14 AM

My situaltion is like this

DB has following data
---

This is the first line.

This is the second line.

<ul>
 <li>This is the first list item </li>
 <li>This is the second list item </li>
</ul>

<table>
 <tr>
   <td>This is a cell data</td>
 </tr>
</table>

---

Now I want to show the data in the user side.. If I will simply put it to a literal the first and second paragraph will come together..  So I want to put a <br /> between them while showing..

The simple way is to replace all \n with <br />.. But that will put <br /> everywhere even after <ul>, <li>, <table> and everywhere...

Aug 7, 2009 at 8:35 AM

This sounds like a question you can ask on StackOverflow.com

Questions are usually answered within 30minutes, atleast some kind of reply.