I have xml records with javascript code embedded in an element. Like:
<?xml version="1.0" encoding="UTF-8"?>
<xml>
<script>
<sys_id>011fb5f68fb679a200b0af5a531815ae</sys_id>
<sys_updated_on>2010-06-04 04:05:18</sys_updated_on>
<js_script>function myJavascriptFunction(){
var count =0 ;
alert('entering myJavascriptFunction');
}
</js_script>
<name>myJavascriptFunction</name>
</script>
</xml>
this file is saved as a .xml file (but I would be happy to change the suffix if it helped).
The purpose of this is that a command line utility roundtrips the files into a database.
I would like to quickly edit the script element using something like notepad++ – with javascript language formatting help. Then I’d like to save the script element contents back to the file.
I have considered “inverting” the file and saving javascript element contents directly as a .js file and put the xml elements into extended file properties. This would make it easy to edit with language support, but it feels like a lot of work and then the files are not easily transportable across OS and source control systems.
Am I missing something obvious?
Is there a clever approach to this?
Put your script inside of a CDATA section