Jump to content

XmlTools/Full documentation: Difference between revisions

m
Line 647: Line 647:
===Description===
===Description===


This operation allows you to use [[wikipedia:JavaScript|JavaScript]] to edit XML. <u>You should use this option only as '''last resort'''</u>, because it is '''MUCH slower''' than all the other native options.
This operation allows you to use [[wikipedia:JavaScript|JavaScript]] to edit XML.  


You can use this for complex logics and mathematical operations which aren't supported in other native operations.
You can use this for complex logics and mathematical operations which aren't supported in other native operations.
<u>You should only use this option as '''last resort'''</u> if you are using it for [[Anniversary_Edition/Framework#XML_patching|AE Patches]], because it is '''MUCH slower''' than all the other native options. Try <u>maintain your code as optimized as possible</u>, as the user code also highly affects the XmlTools performance while applying the patch.


Usage:
Usage:
Line 665: Line 667:
The <tt>$xmlData</tt> global variable contains the XML of the current file. After you modify the XML, update this variable again with the new XML in order to XmlTools update correctly the file.
The <tt>$xmlData</tt> global variable contains the XML of the current file. After you modify the XML, update this variable again with the new XML in order to XmlTools update correctly the file.


XmlTools uses the [http://www.petetracey.com/jsxml/index.html JSXML XML Tools] JavaScript libraries, specifically you will use the JSXMLBuilder class to edit the XML. You can read it documentation in its [http://www.petetracey.com/jsxml/documentation.html website] or [http://script10k.oni2.net/documentation/xmltools/jsxml-documentation.htm here].
XmlTools uses the [http://www.petetracey.com/jsxml/index.html JSXML XML Tools] JavaScript libraries to allow you to edit the XML. You can read it documentation in its [http://www.petetracey.com/jsxml/documentation.html website] or [http://script10k.oni2.net/documentation/xmltools/jsxml-documentation.htm here].


===Example===
===Example===
Line 684: Line 686:
      
      
       <span style="color:green">// Loop over all characters</span>
       <span style="color:green">// Loop over all characters</span>
       for (var i=0; i<(charactersNode.childElement(i)); i++){ <span style="color:green">// the condition checks if the ith element exists (!= undefined)</span>
       for (var i=0; (charactersNode.childElement(i)); i++){ <span style="color:green">// the condition checks if the ith element exists (!= undefined)</span>
      
      
               var currChar=charactersNode.childElement(i);
               var currChar=charactersNode.childElement(i);
489

edits