XmlDocument

From Liberty Unleashed Wiki
Jump to: navigation, search
Home   |   Squirrel Scripting   |   Server Functions   |   Server Events   |   Client Functions   |   Client Events

This function adds a XML Element to the document given.

Syntax

  1. XmlElement XmlElement( string ElementName )

Arguments

  • ElementName - The name of the element you wish to add.

Example

This will load an XML document into the scripts and add an element to it, setting element's attribute to current time.

  1.  
  2. function onScriptLoad()
  3. {
  4. local myDocument = XmlDocument();
  5. myDocument.LoadFile( "Example.xml" );
  6. local element = XmlElement("Info");
  7. element.SetAttribute( "Time", GetFullTime() );
  8. myDocument.LinkChild( element );
  9. myDocument.SaveFile();
  10. }
  11.  

Output

  1. <Info Time="Wed Jul 03 16:37:54 2013" />

Notes

The callback onScriptLoad and the functions XmlDocument, XmlDocument.LoadFile, XmlElement.SetAttribute,XmlDocument.SaveFile were used in this example. More info about it is available in the corresponding pages.

Related Functions

Personal tools
Namespaces

Variants
Actions
Navigation
scripting
Toolbox