com.GameInterface.GUIUtils.XmlParser

Parses XML to values in an object and handles methods for simple retrieval of these values

Summary
com.GameInterface.GUIUtils.XmlParserParses XML to values in an object and handles methods for simple retrieval of these values
Variables
m_Values
Functions
XmlParserThe constructor, retrives an XMLNode, sets up the toplevel object and starts parsing the xml
recursiveXmlLoopRecursive looping and parsiing of XML, parses the attributes first if available, proceeds with the elements, if any sub elements the function calls itself repeditly
getAttributesReads all the attributes of an XML, if attribute is empty it is omitted
GetValueLooks up the internal getValueByName method and return its values
getValueByNamerecursive function that loops the m_Values object looking for textual matches, and returns all possible
hasAttributeattempts to iterate the XMLNode’s attributes, returns true if there are any attributes to iterate

Variables

m_Values

private var m_Values: Object

Functions

XmlParser

public function XmlParser(p_xml: XMLNode)

The constructor, retrives an XMLNode, sets up the toplevel object and starts parsing the xml

Parameters

p_xml:XMLNode - the fragment xml to parse

Returns

void

recursiveXmlLoop

private function recursiveXmlLoop(p_xmlnode: XMLNode,
p_valueobject: Object) : Void

Recursive looping and parsiing of XML, parses the attributes first if available, proceeds with the elements, if any sub elements the function calls itself repeditly

Parameters

p_xmlnode:XMLNode - the xmlnode to parse
p_valueobject:Object - the Object at the correct point where you wuuld like to insert the parsed values

Returns

Void

getAttributes

private function getAttributes(p_xmlnode: XMLNode,
p_valueobject: Object) : Object

Reads all the attributes of an XML, if attribute is empty it is omitted

Parameters

p_xmlnode:XMLNode - the xmlnode to parse
p_valueobject:Object - the Object at the correct point where you would like to insert the parsed values

Returns

Object - the object (or associative array if you will ) where the values are inserted

GetValue

public function GetValue(p_name: String)

Looks up the internal getValueByName method and return its values

Parameters

p_name:String

Returns

string, null or Object depending if one, zero or multiple items are found

getValueByName

private function getValueByName(p_name: String,
p_valueobject: Object)

recursive function that loops the m_Values object looking for textual matches, and returns all possible

Parameters

p_name:String - the name of the prop to return
p_valueobject:Object - the object you are inspecting

Returns

string, null or Object depending if one, zero or multiple items are found

hasAttribute

public function hasAttribute(p_context: XMLNode)

attempts to iterate the XMLNode’s attributes, returns true if there are any attributes to iterate

Parameters

p_context:XMLNode - the xmlnode to inspact for attributes

Returns

Boolean true if attributes exist, false if not

private var m_Values: Object
public function XmlParser(p_xml: XMLNode)
The constructor, retrives an XMLNode, sets up the toplevel object and starts parsing the xml
private function recursiveXmlLoop(p_xmlnode: XMLNode,
p_valueobject: Object) : Void
Recursive looping and parsiing of XML, parses the attributes first if available, proceeds with the elements, if any sub elements the function calls itself repeditly
private function getAttributes(p_xmlnode: XMLNode,
p_valueobject: Object) : Object
Reads all the attributes of an XML, if attribute is empty it is omitted
public function GetValue(p_name: String)
Looks up the internal getValueByName method and return its values
private function getValueByName(p_name: String,
p_valueobject: Object)
recursive function that loops the m_Values object looking for textual matches, and returns all possible
public function hasAttribute(p_context: XMLNode)
attempts to iterate the XMLNode’s attributes, returns true if there are any attributes to iterate
Close