489
edits
| Script 10k (talk | contribs)  (→Example:  adding the example) | Script 10k (talk | contribs)  m (→@CUSTOM_CODE) | ||
| Line 665: | Line 665: | ||
| 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  | 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]. | ||
| ===Example=== | ===Example=== | ||
| Line 675: | Line 675: | ||
|   <nowiki><code></nowiki> |   <nowiki><code></nowiki> | ||
|         var myBuilder = new JSXMLBuilder(); |         var myBuilder = new JSXMLBuilder(); | ||
|         myBuilder.load($xmlData); |         myBuilder.load($xmlData); <span style="color:green">// Load the XML of the file for editing using the global variable</span> | ||
|         var elements = myBuilder.elements[0]; |         var elements = myBuilder.elements[0]; | ||
| Line 691: | Line 691: | ||
|                if(currChar.childElement("OSD").childElement("Team").text=="TCTF"){ |                if(currChar.childElement("OSD").childElement("Team").text=="TCTF"){ | ||
|                       <span style="color:green">// Get  |                       <span style="color:green">// Get ammo and cell 'Use' XML elements</span> | ||
|                       currAmmoElement=currChar.childElement("OSD").childElement("Inventory").childElement("Ammo").childElement("Use"); |                       currAmmoElement=currChar.childElement("OSD").childElement("Inventory").childElement("Ammo").childElement("Use"); | ||
|                       currCellsElement=currChar.childElement("OSD").childElement("Inventory").childElement("EnergyCell").childElement("Use"); |                       currCellsElement=currChar.childElement("OSD").childElement("Inventory").childElement("EnergyCell").childElement("Use"); | ||
|                       <span style="color:green">// Add +1 to the current  |                       <span style="color:green">// Add +1 to the current amount of ammo and cells to use</span> | ||
|                       currAmmoElement.text=parseInt(currAmmoElement.text)+1; |                       currAmmoElement.text=parseInt(currAmmoElement.text)+1; | ||
|                       currCellsElement.text=parseInt(currCellsElement.text)+1; |                       currCellsElement.text=parseInt(currCellsElement.text)+1; | ||
edits