开发者

add characters to end of line

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜