About XML
XML (Extensible Markup Language) is becoming the standard for the interchange of structured
data in Internet applications. You can integrate data in Flash with servers that use XML
technology to build sophisticated applications, such as chat systems or brokerage systems.
In XML, as with HTML, you use tags to mark up, or specify, a body of text. In HTML, you use
predefined tags to indicate how text should appear in a web browser (for example, the
indicates that text should be bold). In XML, you define tags that identify the type of a piece of
data (for example,
information from the way it's displayed, so the same XML document can be used and reused in
different environments.
Every XML tag is called a node, or an element. Each node has a type (1, which indicates an XML
element, or 3, which indicates a text node), and elements may also have attributes. A node nested
in a node is called a child node. This hierarchical tree structure of nodes is called the XML
Document Object Model (DOM)—much like the JavaScript DOM, which is the structure of
elements in a web browser.
In the following example,
child node
<HOLDING>
<PORTFOLIO>
<HOLDING SYMBOL="RICH"
QTY="75"
PRICE="245.50"
VALUE="18412.50" />
</PORTFOLIO>
Using the XML class
The methods of the ActionScript XML class (for example,
insertBefore()
interpret downloaded XML data.
The following XML class methods send and load XML data to a server by using the HTTP
method:
POST
•
The
method downloads XML from a URL and places it in an ActionScript
load()
XML object.
•
The
method passes an XML object to a URL. Any returned information is sent to
send()
another browser window.
•
The
sendAndLoad()
placed in an ActionScript XML object.
For example, you could create a brokerage system that stores all its information (user names,
passwords, session IDs, portfolio holdings, and transaction information) in a database.
<password>VerySecret</password>
<PORTFOLIO>
, which has the attributes
) let you structure XML data in Flash to send to a server and manipulate and
method sends an XML object to a URL. Any returned information is
Sending and loading variables to and from a remote source
). XML separates the structure of the
is the parent node; it has no attributes and contains the
,
,
SYMBOL
QTY
PRICE
appendChild()
<b>
, and
:
VALUE
,
removeNode()
tag
, and
181
Need help?
Do you have a question about the FLASH MX 2004 - ACTIONSCRIPT and is the answer not in the manual?