Reputation: 17
How do I add </in>
to the end of each line?
A String contain:
<ch>13</ch><in>Item 13(mono)
<ch>14</ch><in>Item 14(mono)
<ch>15</ch><in>Item 15(mono)
Upvotes: 0
Views: 95
Reputation: 6127
To replace each line break with </in>
and a line break, you could try something like this:
myString = myString.replace(/\n/g, "</in>\n");
But if the strings contains the extra white space, extra empty lines, in your example, you would probably end up with an extra </in>
there too. So to get valid XML, you would probably have to do more than the above.
Upvotes: 1