Solved

Reading XML into dataset and keeping line break from XML

Posted on 2007-12-01
4
940 Views
Last Modified: 2012-06-27
I am reading information from a XML file into a Dataset and loading it to a webpage.  I wanted to keep the format from the XML file such as line break (see code example).  I loaded the xml to dataset as ds.ReadXml(filename) and loaded it do a table.  How can i make line break from text in <blog> in XML file appear in webpage??

<Comments>

    <Name>VAldimf</Name>

    <Time>01.12.2007 12:14:43</Time>

    <Title>slasfdj</Title>

    <Blog>valdij

södfj
 
 
 

asdföj

adsfj
 

asdföj

sadf</Blog>

    <ID>4</ID>

  </Comments>
 
 

...

            foreach (DataRow dr in ds.Tables[0].Rows)

            {

                TableRow tr = new TableRow();

                tr.Cells.Add(new TableCell());

...

                tr.Cells[0].Text = "<FONT size = 2 FACE = Verdana color = #8F8672 >" + dr[3].ToString() + "</FONT>";

                this.BlogTable.Rows.Add(tr);

.....

Open in new window

0
Comment
Question by:va80
  • 2
4 Comments
 
LVL 40

Expert Comment

by:evilrix
ID: 20387943
0
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 200 total points
ID: 20387951
Use :
tr.Cells[0].Text = "<FONT size = 2 FACE = Verdana color = #8F8672 >" + dr[3].ToString().Replace("\n","<br>") + "</FONT>";
               
Replace real newlines with the <br> tag.
0
 
LVL 40

Expert Comment

by:evilrix
ID: 20387953
http://msdn2.microsoft.com/en-us/library/ms256097.aspx

So, try this: -


Comments>

    <Name>VAldimf</Name>

    <Time>01.12.2007 12:14:43</Time>

    <Title>slasfdj</Title>

    <Blog xml:space="preserve">valdij

södfj

 

 

 

asdföj

adsfj

 

asdföj

sadf</Blog>

    <ID>4</ID>

  </Comments>

Open in new window

0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Syntax Error 2 46
Server Error 11 47
IIS Authorization for Web Service 2 22
Webform example, External Authentication Services, OAUTH, asp.net 4.6.2 1 15
Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

920 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now