views:

49

answers:

2

This is partly related to the age-old unix vs. windows newline LF/CRLF dilemma. I don't love my solution, but I have most of that figured out... (nonetheless any general guidance related to cross-browser newlines appreciated!). FF can send data from html textareas in a way that the newlines are stored in the db consistently with IE (and my Java client). The other clients can read these FF-authored strings newline and all.

My main remaining issue is how to correctly retrieve and display the strings in FF. How can I identify newlines in xml attributes? For example, I have an xhr returning a set of form fields to render via javascript:

<field name="desc" displayname="Description" value="i
am
in
ff" type="string" length="240"> </field>

(I haven't confirmed, but I'm pretty sure those are CRLFs in the value attribute - same as I stored previously...) This value will get rendered into a textarea.

But when I try to read the attribute in FF, var value = fieldNode.getAttribute( "value" ); I get value="i am in ff"

I know if i convert the CRLF to \n on the server, FF will work; but i think this may cause problems for our other clients. I'd like to find a client-side and client-specific solution.

If I could detect the newlines, I could substitute in
or whatever. I just need a way to detect them.

ps - no responses after more than a month... why am I the only one with this problem?? guess I'll have to figure it out myself :(

A: 

Just in case anyone else stumbles on this in the futre... This thread helped get me on the right track: http://stackoverflow.com/questions/2004386/how-to-save-newlines-in-xml-attribute

As it turns out, CRLF, CR, and LF should get encoded in proper xml CRLF = & #xD;& #xA;). I was previously not encoding these. IE is tolerant of that, while other browsers are not. E.g., Firefox's XML parser converts any newline character to a space. Now that i am encoding the newlines, all is well...

ss ulrey
A: 
adustduke