I must copy a <script>
node from xml to html, but I need to replace dinamically some lines of it, and also add new ones. So I need to search-and-replace strings while the entire node is copying.
XML example:
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
id="slot" width="320" height="245">
<script type="application/javascript"><![CDATA[
var a = 2;
var b = "abc";
var c = new Array(0,0,0);
alert("Input!");
]]></script>
<!-- here svg drawing tags -->
</svg>
HTML output example:
<html>
<head>
<title>Example!</title>
<script type="application/javascript">
var a = 2; <!---same as xml--->
var b = "def"; <!---modified--->
var c = new Array(0,0,0); <!---same as xml--->
alert("This is a new example!"); <!---modified--->
var new = "new var"; <!---new code--->
</script>
</head>
<body>
</body>
</html>
If it's much easy, I can use XTLS 2.0. How can I do?
This transformation:
when applied on the provided XML document:
produces the wanted result (all commands carried out and the script edited):