How do I add </in>
to the end of each line?
A String contain:
<ch>13</ch><in>Item 13(mon开发者_运维技巧o)
<ch>14</ch><in>Item 14(mono)
<ch>15</ch><in>Item 15(mono)
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.
精彩评论