XmlUtil
| Kind of class: | class |
|---|---|
| Inherits from: | none |
| Version: | 01/24/07 |
| Author: | Aaron Clinger, Mike Creighton |
| Classpath: | org.casaframework.util.XmlUtil |
| File last modified: | Thursday, 25 January 2007, 09:21:18 |
Summary
Class methods
extractText
static function extractText (
node:XMLNode) : String
Traverses recursively through an XMLNode and its children returning the value of all text within.
Parameters:
node:
XMLNode to be traversed.
Returns:
String containing all text nodes' nodeValues concatenated together.
getChildNodeByName
static function getChildNodeByName (
context:XMLNode,
name:String) : XMLNode
Traverses through the child nodes and returns the first node it finds that matches specified name.
Parameters:
context:
Node that contains the child nodes you are searching.
name :
Name of the target node.
Returns:
Returns the first node that matched specified name.
getChildNodesByName
static function getChildNodesByName (
context:XMLNode,
name:String) : Array
Traverses through the child nodes and returns all nodes it finds that matches specified name.
Parameters:
context:
Node that contains the child nodes you are searching.
name :
Name of the target nodes.
Returns:
Returns an Array comprised of nodes that matched specified name.
getTextOfChildNodeByName
static function getTextOfChildNodeByName (
context:XMLNode,
name:String) : String
Traverses through the child nodes and returns the text content of the first node it finds that matches specified name.
Parameters:
context:
Node that contains the child nodes you are searching.
name :
Name of the target node.
Returns:
Returns the text value of the node.
getTextOfChildNodesByName
static function getTextOfChildNodesByName (
context:XMLNode,
name:String) : Array
Traverses through the child nodes and returns the text content of the first node it finds that matches specified name.
Parameters:
context:
Node that contains the child nodes you are searching.
name :
Name of the target nodes.
Returns:
Returns an Array comprised of the text values of the nodes that matched specified name.
objectToXml
static function objectToXml (
objectData:Object) : XML
Returns XML converted from an Object.
Parameters:
objectData:
Basic Object to be coverted.
Returns:
XML Object comprised of passed Object's data.
Example:
var xmlObject:Object = new Object(); this.xmlObject.wrapper = new Object(); this.xmlObject.wrapper.group = "friends"; this.xmlObject.wrapper.name = new Array("Greg", "Jose", "Dave", "Toby"); var xmlData:XML = XmlUtil.objectToXml(this.xmlObject); trace(this.xmlData);
Usage note:
xmlToObject
static function xmlToObject (
xmlData:XML,
convertNumbers:Boolean,
convertBooleans:Boolean) : Object
Returns an easily navigable object from XML.
Parameters:
xmlData :
Defined or loaded XML to be coverted.
convertNumbers :
[optional] Indicates to either convert number strings to numbers
true, or leave all numbers as strings false; defaults to true.convertBooleans:
[optional] Indicates to either convert
"true"/"false" strings to proper booleans true, or leave all booleans as strings false; defaults to true.Returns:
An Object comprised of Arrays.
Example:
var birthdayXml:XML = new XML("<birthday><people><person><name>Aaron Clinger</name><birthdate month=\"January\" day=\"11\" /></person><person><name>John Doe</name><birthdate month=\"April\" day=\"21\" /></person></people></birthday>"); var xmlObject:Object = XmlUtil.xmlToObject(this.birthdayXml); trace("Name is " + this.xmlObject.birthday[0].people[0].person[1].name[0]); trace("Day born is " + this.xmlObject.birthday[0].people[0].person[1].birthdate[0].day);