DXML Help File

DXML Help File

Plugin Name:

DXML

Current Version:

1.2.2.1

Description:

Dynamic XML is an extension of the XML functions for AMS. It allows the programmer to load and work with multiple XML files at the same time.

Notes on Compatibility:
DXML was designed to be compatible with the original XML functions, it can used with the other XML functions as long as you use the extra compatibility functions provided, although there is really no need to use the normal XML functions as all of them are included in DXML.

Licence:

Free to use and distribute.

Author:

Centauri Soldier

Web:

www.AMSPublic.com

E-mail:

centaurisoldier@AMSPublic.com

Copyright:

Copyright © 2010 AMSPublic.com

Install Notes:

Place the "DXML" Folder in your "AutoPlay Media Studio/Plugins/Actions" folder.


Table of Contents

DXML.Count
DXML.GetActive
DXML.GetAttribute
DXML.GetAttributeNames
DXML.GetElementNames
DXML.GetElementXML
DXML.GetLoaded
DXML.GetValue
DXML.GetXML
DXML.InsertXML
DXML.IsSaved
DXML.ReadFromFile
DXML.ReadFromString
DXML.RemoveAttribute
DXML.RemoveElement
DXML.Save
DXML.SaveAll
DXML.SetActive
DXML.SetAttribute
DXML.SetFilePath
DXML.SetValue
DXML.SortByElement
DXML.StringToXMLAtt
DXML.UnloadTable
DXML.XMLAttToString

DXML.Count


(number) DXML.Count ( 

(string) XMLTable = "Test",

(string) XMLPath = "root/element/element",

(string) ElementName = "*" )

Description

Counts the number of elements below a given XML path that match a given element name.

Parameters

XMLTable

(string) The name of the XML table

XMLPath

(string) The full path to the element whose children you want to count.

ElementName

(string) The element name (tag name) that you want to search for. Only elements that match will be counted. Use * to match any name.

Returns

(number) The number of matching child elements found. If an error occurs, -1 is returned. You can use Application.GetLastError to determine whether this action failed, and why


DXML.GetActive


(string) DXML.GetActive ()

Description

Returns the active XML table.

Returns

(string) Returns a string.
If an error occurs or there is no active table then a blank string is returned.


DXML.GetAttribute


(string) DXML.GetAttribute ( 

(string) XMLTable = "Test",

(string) XMLPath = "root/element/element",

(string) AttributeName = "MyAttribute" )

Description

Returns the value of an element's attribute.

Parameters

XMLTable

(string) The name of the XML table.

XMLPath

(string) The full path to the element whose attribute names you want to retrieve.

AttributeName

(string) The full path to the element whose attribute you want to retrieve.

Returns

(string) The value of the specified element's attribute. If an element has no attribute or an error occurs, an empty string ("") is returned. You can use Application.GetLastError to determine whether this action failed, and why.


DXML.GetAttributeNames


(table) DXML.GetAttributeNames ( 

(string) XMLTable = "Test",

(string) XMLPath = "root/element/element" )

Description

Returns the names of an element's attributes in a numerically indexed table.

Parameters

XMLTable

(string) The name of the XML table.

XMLPath

(string) The full path to the element whose attribute names you want to retrieve.

Returns

(table) A numerically indexed table containing the names of the specified element's attributes. If the element doesn't contain any attributes or an error occurs, nil is returned. You can use Application.GetLastError to determine whether this action failed, and why.


DXML.GetElementNames


(table) DXML.GetElementNames ( 

(string) XMLTable = "Test",

(string) XMLPath = "root/element/element",

(boolean) FullPaths = false,

(boolean) IncludeIndices = false )

Description

Returns a numerically indexed table containing the names of all child elements contained within a specific element.

Parameters

XMLTable

(string) The name of the XML table.

XMLPath

(string) The full path to the element whose child elements you want to find.

FullPaths

(boolean) Whether to return the full paths of the child elements, or just the element names:

Value

Description

true

Return the full paths of the child elements.

false

(Default) Return just the element names. (Default)

IncludeIndices

(boolean) Whether to append the delimiter and index (e.g. ":3") to each element name:

Value

Description

true

Append the delimiter and index to each element name.

false

(Default) Return just the element names. (Default)

Returns

(table) A numerically indexed table containing the names of all child elements contained within the specified element. If there are no child elements or an error occurs, nil is returned. You can use Application.GetLastError to determine whether this action failed, and why.


DXML.GetElementXML


(string) DXML.GetElementXML ( 

(string) XMLTables = "Test",

(string) XMLPath = "root/element/element" )

Description

Returns the raw XML of an element, i.e. the plain-text XML code for the element and all of its children.

Parameters

XMLTables

(string) The name of the XML table.

XMLPath

(string) The full path to the element whose XML you want to retrieve.

Returns

(string) The XML code for the entire element and all of its children. If the element doesn't exist, or an error occurs, an empty string ("") is returned. You can use Application.GetLastError to determine whether this action failed, and why.


DXML.GetLoaded


(table) DXML.GetLoaded ()

Description

Returns all the loaded XML files.

Returns

(table) Returns a numerically indexed table containing the names of all the loaded XML files.
If an error occurs or there are no loaded files then nil is returned.


DXML.GetValue


(string) DXML.GetValue ( 

(string) XMLTable = "Test",

(string) XMLPath = "root/element/element" )

Description

Returns the value of an element.

Parameters

XMLTable

(string) The name of the XML table.

XMLPath

(string) The full path to the element whose value you want to retrieve.

Returns

(string) The value of the specified element. If the element contains no value, or an error occurs, an empty string ("") is returned. You can use Application.GetLastError to determine whether this action failed, and why.


DXML.GetXML


(string) DXML.GetXML ( 

(string) XMLTable = "Test" )

Description

Returns the specified XML document as a string.

Parameters

XMLTable

(string) The name fo the XML table.

Returns

(string) A string containing the specified XML table. If the table does not exist or an error occurs, an empty string ("") is returned. You can use Application.GetLastError to determine whether this action failed, and why.


DXML.InsertXML


DXML.InsertXML ( 

(string) XMLTable = "Test",

(string) XMLPath = "root/element/element",

(string) Text = "value1value2",

(variant) InsertionMode = XML.INSERT_AFTER )

Description

Inserts raw XML code into a specific location in the specified XML table.

Parameters

XMLTable

(string) The name of the XML table.

XMLPath

(string) The path to the element where you want to insert the XML text. You can insert the XML before this element, insert it after this element, or replace the element (and all its children) with the new XML text.

Text

(string) The XML text that you want to insert.

InsertionMode

(variant) The insertion mode to use:

CONSTANT

VALUE

DESCRIPTION

XML.INSERT_BEFORE

0

Insert the new XML text before the specified element.

XML.INSERT_AFTER

1

Insert the new XML text after the specified element.

XML.REPLACE

2

Replace the specified element's XML text with the new XML text.

Returns

This action dose not return any value.


DXML.IsSaved


(boolean) DXML.IsSaved ( 

(string) XMLTable = "Test" )

Description

Determines whether or not an XML table has been saved since it was last changed.

Parameters

XMLTable

(string) The name of the XML table.

Returns

(boolean) retuns true it the specified table has been saved since its last change and false if it has not.
If an error occurs or the table does not exist then false is returned.


DXML.ReadFromFile


DXML.ReadFromFile ( 

(string) File = "C:\\MyFile.XML",

(string) XMLTable = "Test" )

Description

Loads an XML file into memory.

Parameters

File

(string) The full path to the XML file.

XMLTable

(string) The name of the XML table in which to load the XML file contents.

Returns

This action dose not return any value.


DXML.ReadFromString


DXML.ReadFromString ( 

(string) File = "C:\\MyFile.xml",

(string) XMLTable = "Test",

(string) String = "" )

Description

Loads an XML string into memory.

Parameters

File

(string) The full path to the file where the XML string will be saved.

Note: This argument is not required but if it is not set then the XML data cannot be saved to file without first calling DXML.SetFilePath().

XMLTable

(string) The name of the XML table in which to load the XML string.

String

(string) The String which will be loaded.

Returns

This action dose not return any value.


DXML.RemoveAttribute


DXML.RemoveAttribute ( 

(string) XMLTable = "Test",

(string) XMLPath = "root/element/element",

(string) AttributeName = "MyAttribute" )

Description

Removes a specific attribute from an element.

Parameters

XMLTable

(string) The name of the XML table.

XMLPath

(string) The path to the element whose attribute you want to remove.

AttributeName

(string) The name of the attribute you want to remove.

Returns

This action dose not return any value.


DXML.RemoveElement


DXML.RemoveElement ( 

(string) XMLTable = "Test",

(string) XMLPath = "root/element/element" )

Description

Removes a specific element (and its children) from the specified XML table.

Parameters

XMLTable

(string) The name of the XML table.

XMLPath

(string) The path to the element you want to remove.

Returns

This action dose not return any value.


DXML.Save


(boolean) DXML.Save ( 

(string) XMLTable = "Test" )

Description

Saves the specified XML table to it's relevant file.

Note: File paths are stored when XML documents are loaded. If XML is created without loading a file then a file path must be specified using the DXML.SetFilePath() function.

Parameters

XMLTable

(string) The name of the XML table.

Returns

(boolean) Returns true if the file was saved and false if it was not.


DXML.SaveAll


(table) DXML.SaveAll ()

Description

Saves all XML tables to their appropriate files.

Returns

(table) Returns a numerically indexed table containing all of the XML table names that were not saved to file (most likely because no file path was specified).

If all tables were saved to file or no tables exist then nil is returned.


DXML.SetActive


DXML.SetActive ( 

(string) XMLTable = "Test" )

Description

Manually sets the active XML table.

Note: This action is automatically called by all DXML functions which need it and is not required (to be called manually) for DXML functions to operate properly. This function is here for the sake of versatility.

Parameters

XMLTable

(string) The name of the XML table to make the active table.

Returns

This action dose not return any value.


DXML.SetAttribute


DXML.SetAttribute ( 

(string) XMLTable = "Test",

(string) XMLPath = "root/element/element",

(string) AttributeName = "MyAttribute",

(string) AttributeValue = "MyValue" )

Description

Sets the value of an element's attribute.

Parameters

XMLTable

(string) The name of the XML table.

XMLPath

(string) The path to the element whose attribute you want to set.

AttributeName

(string) The name of the attribute you want to set.

AttributeValue

(string) The value you want the attribute to have.

Returns

This action dose not return any value.


DXML.SetFilePath


DXML.SetFilePath ( 

(string) XMLTable = "Test",

(string) File = "C:\\NewFile.xml" )

Description

Sets or changes the file save path for a specified XML table.

Note: File paths are nomally set during XML string or file loading. This action is used if the file path was not set during the loading process or to simply change where a file will be saved.

Parameters

XMLTable

(string) The name of the XML table.

File

(string) The full file path to which the specified table's file path will be changed.

Returns

This action dose not return any value.


DXML.SetValue


DXML.SetValue ( 

(string) XMLTable = "Test",

(string) XMLPath = "root/element/element",

(string) Value = "MyValue",

(boolean) WriteCDATA = false )

Description

Sets the value of an element.

Parameters

XMLTable

(string) The name of the XML table.

XMLPath

(string) The full path to the element whose value you want to set.

Value

(string) The value you want the element to have.

WriteCDATA

(boolean) Whether to write the data as a CDATA section:

Value

Description

true

Write the data as a CDATA section.

false

(Default) Don't write the data as CDATA. (Default)

Returns

This action dose not return any value.


DXML.SortByElement


DXML.SortByElement ( 

(string) XMLTable = "Test",

(string) Path = "root/element/element" )

Description

Alphabetically sorts an XML table according to the values of the specified element.

Parameters

XMLTable

(string) The name of the XML table to sort.

Path

(string) The path to the element that will be the sorting target.

Returns

This action dose not return any value.


DXML.StringToXMLAtt


(string) DXML.StringToXMLAtt ( 

(string) Input = "",

(string) Control Character = "¬" )

Description

Converts a string into another string that will be able to be stored as an xml string, replacing xml control characters(line breaks, ", ', \, <, >, =) with a different and specific control character which is numerically indexed automatically to identify each character type.

Parameters

Input

(string) The string to convert.

Control Character

(string) The character which will replace all of the xml control characters in the string.

CONSTANT

VALUE

DESCRIPTION

"•"

"•"

NA

"¤"

"¤"

NA

"¥"

"¥"

NA

"¬"

"¬"

NA

Returns

(string) Returns the converted string.


DXML.UnloadTable


DXML.UnloadTable ( 

(string) XMLTable = "Test" )

Description

Removes a specified XML table from memory.

Parameters

XMLTable

(string) The name of the XML table to remove from memory.

Returns

This action dose not return any value.


DXML.XMLAttToString


(string) DXML.XMLAttToString ( 

(string) Input = "Here¬3s some text.",

(string) Control Character = "¬" )

Description

Converts a string, previously converted by the DXML.StringToXMLAtt() function, back to a normal string using the specified control character.

Parameters

Input

(string) The previously-converted xml string to convert back to a normal string.

Control Character

(string) The control character used during the initial encoding process.

CONSTANT

VALUE

DESCRIPTION

"•"

"•"

NA

"¤"

"¤"

NA

"¥"

"¥"

NA

"¬"

"¬"

NA

Returns

(string) Returns the converted string.



Copyright © 2010 AMSPublic.com
This File Was Generated With AMS ActionFile Editor