org.silex.core.XmlDom

XmlDom class deals with xml files.  XML FORMAT USED FOR THE COMMUNICATION WITH FLASH, SERIALISATION, ETC.  <object><property id=’var1’><string>aaaaaaaaaaa</string></property><property id=’var2’><string name=\”testName2\”>bbbbbbbbbb</string></property></object> <object><property id=”param2”><string>commandParam2</string></property><property id=”param1”><string>commandParam1</string></property></object> <string>stringCommandParam1</string> <object><property id=’success’><bool>false</bool></property><property id=’message’><string>Dummy error</string></property></object> DATA TYPES http://www.python.org/doc/2.4.4/lib/types.html Numeric types -- int, float, long Sequence Types -- str bool list, dict illegal characters < < > > & & &apos; ‘ “ “

Author

lex@silex.tv

Summary
org.silex.core.XmlDomXmlDom class deals with xml files.
Variables
silex_ptrreference to silex main Api object (org.silex.core.Api)
XML_TAB_CHARTABS constant for XML files “\t” for easy read xml or “” for production mode
XML_CR_CHARCR constant for XML files “\n” for easy read xml or “” for production mode
versionCurrent silex xml version.
Functions
XmlDomConstructor.
xmlToSimplePathconvert xml string to an ActionScript object
doXmlToSimplePathRecursive function which does the conversion from xml to object.
removeCDATARemove the <![CDATA[ ]]> from a string.
addCDATAAdd the <![CDATA[ ]]> to a string.
objToXmlConvert an object to xml.
doObjToXmlConvert an object to xml.
getTypeRetrieve the type of an object.
escapeHTMLEscape a string to be outputed in an XML file
xmlToObjconvert xml string to an ActionScript object
doXmlToObjRecursive function which does the conversion from xml to object.

Variables

silex_ptr

private var silex_ptr: org.silex.core.Api

reference to silex main Api object (org.silex.core.Api)

XML_TAB_CHAR

public static var XML_TAB_CHAR: String

TABS constant for XML files “\t” for easy read xml or “” for production mode

XML_CR_CHAR

public static var XML_CR_CHAR: String

CR constant for XML files “\n” for easy read xml or “” for production mode

version

var version: Number

Current silex xml version.  Used for compatibility with previous versions.  1 = escaped string and no version info.  2 = current version.

Functions

XmlDom

function XmlDom(api: org.silex.core.Api)

Constructor.

xmlToSimplePath

static function xmlToSimplePath(_xml: XML):Object

convert xml string to an ActionScript object

Parameters

param _xml the xml string

Returns

an ActionScript object

doXmlToSimplePath

private static function doXmlToSimplePath(elem: XMLNode):Object

Recursive function which does the conversion from xml to object.

Parameters

param elem the xml object to convert

Returns

Object

removeCDATA

public function removeCDATA(_str: String):String

Remove the <![CDATA[ ]]> from a string.

Parameters

param _str the string

Returns

the new string

addCDATA

public function addCDATA(_str: String):String

Add the <![CDATA[ ]]> to a string.

Parameters

param _str the string

Returns

the new string

objToXml

public function objToXml(objToConvert: Object):String

Convert an object to xml.

Parameters

param objToConvert ActioinScript object

Returns

The corresponding XML

doObjToXml

private function doObjToXml(objToConvert, 
tab: String,
silexXmlVersion: String):String

Convert an object to xml.  Recursive function.

Parameters

param objToConvert ActioinScript object
param tab string containing tab characters to add at the beginning of the lines - XML formating
param silexXmlVersion Current silex xml version

Returns

The corresponding XML

getType

private function getType(objToConvert: Object):String

Retrieve the type of an object.  It adds the array type to the ActionScript operator typeof.

Parameters

param objToConvert

Returns

a string for the object type: array, object, number, boolean or string

escapeHTML

private function escapeHTML(_str: String):String

Escape a string to be outputed in an XML file

Parameters

param _str the string to escape

Returns

a string formated to be outputed in an XML file

xmlToObj

public function xmlToObj(_xml: XML):Object

convert xml string to an ActionScript object

Parameters

param _xml the xml string

Returns

an ActionScript object

doXmlToObj

private function doXmlToObj(elem: XMLNode,
silexXmlVersion: Number):Object

Recursive function which does the conversion from xml to object.

Parameters

param elem the xml object to convert
param silexXmlVersion silex xml version

Returns

ActionScript object

private var silex_ptr: org.silex.core.Api
reference to silex main Api object (org.silex.core.Api)
public static var XML_TAB_CHAR: String
TABS constant for XML files “\t” for easy read xml or “” for production mode
public static var XML_CR_CHAR: String
CR constant for XML files “\n” for easy read xml or “” for production mode
var version: Number
Current silex xml version.
function XmlDom(api: org.silex.core.Api)
Constructor.
static function xmlToSimplePath(_xml: XML):Object
convert xml string to an ActionScript object
private static function doXmlToSimplePath(elem: XMLNode):Object
Recursive function which does the conversion from xml to object.
public function removeCDATA(_str: String):String
Remove the <![CDATA[ ]]> from a string.
public function addCDATA(_str: String):String
Add the <![CDATA[ ]]> to a string.
public function objToXml(objToConvert: Object):String
Convert an object to xml.
private function doObjToXml(objToConvert, 
tab: String,
silexXmlVersion: String):String
Convert an object to xml.
private function getType(objToConvert: Object):String
Retrieve the type of an object.
private function escapeHTML(_str: String):String
Escape a string to be outputed in an XML file
public function xmlToObj(_xml: XML):Object
convert xml string to an ActionScript object
private function doXmlToObj(elem: XMLNode,
silexXmlVersion: Number):Object
Recursive function which does the conversion from xml to object.