Skip to main content
Inspiring
June 11, 2009
Answered

Cffile - reading text file and keeping line breaks

  • June 11, 2009
  • 1 reply
  • 2351 views

I'm trying to use cffile to read a text document and then add then display the text document contents in a .xml file for an atom feed. Everything is working correctly except it appears that cffile is stripping out the line breaks in the original file so that the contents of the variable that is save no longer has any line breaks. Is there an attribute that I'm missing that will control this behavior or do I need to go about this a different way. Thanks in advance for any insight on this issue.

    This topic has been closed for replies.
    Correct answer ilssac

    Why do you say the line breaks are stripped out?

    If you are just saying this because when you look at the results in your browser.  Recall that the HTML standard ignores all line breaks and most other white space.  A quick view of the source will tell you if the line breaks are there or not.  Using the HTML <pre>...</pre> tags is the proper method for telling a browser not to ignore the whitespace in the source.

    But it is possible that somewhere along the conversion process from text file to XML data line breaks are being stripped.  But then we would need to see important peices of your process to have a chance of helping you.

    1 reply

    ilssac
    ilssacCorrect answer
    Inspiring
    June 11, 2009

    Why do you say the line breaks are stripped out?

    If you are just saying this because when you look at the results in your browser.  Recall that the HTML standard ignores all line breaks and most other white space.  A quick view of the source will tell you if the line breaks are there or not.  Using the HTML <pre>...</pre> tags is the proper method for telling a browser not to ignore the whitespace in the source.

    But it is possible that somewhere along the conversion process from text file to XML data line breaks are being stripped.  But then we would need to see important peices of your process to have a chance of helping you.

    Inspiring
    June 11, 2009

    Thanks Ian, using the htmlcodeformat function on my variable created by cffile before using the xmlformat function when creating the xml did the trick. Thanks for the quick response.