You are here: Home > Programming > Flash programming > XML > XML Path Resolver

XML Path Resolver

Print versionEdit this page
A great improvement to reading XML: this script lets you read an XML file (or nodes) by accessing the node names. No more counting of childNode levels! You can use it to write or change the XML too.

A great benefit is that is does not parse the XML to an object. You can choose to access the nodes as you need them.

The latest version at this time of writing is: http://www.powersdk.com/download/XML_Path_Resolver_v1_3_beta_3.zipexternal link

The code still in development. Check out the discussion threadsexternal link on Flashcoders.

NOTE: to get an attribute, use ._attr (same as with SET REQUESTS below)

From the script:

___________________________________________________________

POWERSDK SOFTWARE CORPORATION
http://www.powersdk.com
COPYRIGHT © 2001-2003 - ALL RIGHTS RESERVED

"Code for a distributed world"

SOFTWARE RELEASED UNDER THE BSD LICENSE
http://www.powersdk.com/license.html 
___________________________________________________________

POWERSDK XML RESOLVER

author:   Theodore E Patrick
email:   ted@powerSDK.com
created:   March 18, 2003
edited:   March 19, 2003
version:  1.03 Beta 2
contributions: Tatsuo Kato, Jos Yule

Overview: Resolver adds Node Name support to the default XML Object.

Access nodes as follows:

x = new XML("<a>blah<t/><t>Hello World</t><t age='1'/></a>")

//GET REQUESTS
trace(x.a)                     //return XMLnode
trace(x.a.t[2])                  //return XMLNode
trace(x.a.t[2].attribute.age)       //return attribute value
trace(x.a._value)               //return XMLNode
trace(x.a.t[1]._value)            //return TextNode Value
trace(x.a.t[2].attribute)         //return Attribute array
trace(x.a._node)               //return XMLNode
trace(x.a.t[1]._node)            //return XMLNode

//SET REQUESTS
x.a._value = "blah22"             //add/edit TextNode Value
x.a.t[1]._value = "Hellllo World"    //add/edit TextNode Value
x.a.t[2]._value = "222 World"       //add/edit TextNode Value
x.a.t[0]._attr.dog = "fido"       //add/edit attribute Value
x.a.t[2]._attr.age = 34          //add/edit Attribute Value
x.a._node = "<superNode/>"         //add Node
x.a.t[0]._node = "<subtNode/>"      //add Node
___________________________________________________________


-- ArthurClemens - 17 May 2003