6 Replies Latest reply on Jun 7, 2015 10:58 PM by tobias.wantzen

    XML: contents.replace() destroys XML elements inside




      I've written a XML scripting rule where all <ul><li>'s are mapped to a paragraph style which uses bulleted lists. There is the possibility that returns occur inside the <li> items. Before cycling through the elements and applying the styles with a scripting rule, I tried to change returns (\r) to hard returns (\n) cycling through all <li>'s with this code:


      _node.contents = _node.contents.replace(/\r/g, '\n');  //change all returns inside <usp><li> to newline


      But I realised that, when there are further XML elements (e.g. <em> or <strong>) inside the <li>, those elements were killed by my .replace() call.


      So my question: How can I achieve changing \r's to \n's and retaining the inside XML structure?


      Thanks in advance