Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 232
  • Last Modified:

Java, HTML and XML

I have web application which contains a questionnaire which users fill in and submit.  

The questionnaire is generated by a Java servlet using an XML File for the structure.  

When the user clicks on 'edit questionnaire', the java servlet is called.  The servlet retrieves the XML files and reads the file into a vector.  It then manipulates the vector to produce the the HTML questionnaire in edit mode for the user to complete.

Now here is where I am having trouble.  On the questionnaire in edit mode is a number of textarea fields.  If the user places a character return in the field to created a new line and saves the form, I need to capture this and place '<br>' in it place otherwise my XML file becomes invaid  and it places the node values over two line which knocks all my code out.

e.g

Should be:  <node1>myvalue<br>myvalue2</node1>

Currently: <node1>myvalue
                        myvalues2</node1>

Does anybody know how I can capture the character return in a textarea field and replace it with the '<br>' value?

Thanks in advance.
0
fayeb
Asked:
fayeb
  • 3
1 Solution
 
objectsCommented:
s.replaceAll("\n", "<br>");
0
 
objectsCommented:
Have you thought of using XSL to generate the HTML from the XML?
0
 
applekannaCommented:
this is not exactly your solution but the problem and solution idea here is the same

http://oldlook-search.experts-exchange.com/Web/Web_Languages/JSP/Q_20791591.html
0
 
CEHJCommented:
If that node can contain a line break, it must be <br /> as <br> would not be well-formed XML.
0
 
objectsCommented:
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now