Adobe 65036570 - Director - PC User Manual page 418

User guide
Hide thumbs Also See for 65036570 - Director - PC:
Table of Contents

Advertisement

put gParserObject.child[1].child[1].attributeName.count
-- 2
Parser objects and XML nodes
As described in earlier sections, the parser object in the
of the XML document. An XML node is a node within the tree. The root node is like an XML node because almost
all the operations on XML nodes can be applied to the root node.
In the previous XML example, the root of the tree is an XML element node named
has no attributes and one child (the
child nodes.
The following script returns the root node's type, name, and number of children:
put gParser.type, gParser.name, gParser.count(#child)
-- #element "ROOT OF XML DOCUMENT" 1
The main difference between the root node and its child nodes is that several script methods apply to the entire XML
document and operate on the root node only. These methods include
,
ignoreWhiteSpace()
makeList()
Treating white space
The default behavior of the XML Parser Xtra is to ignore character data between XML tags when all the characters
are white space. This type of white space is usually due to return characters and superfluous space characters, but
sometimes it can have meaning to the XML document.
Use the
ignoreWhiteSpace()
to
instead of its default value of
FALSE
The following script statements leave
into a list. The
element has no children in the list.
sample
XMLtext = "<sample> </sample>"
parserObj.parseString(XMLtext)
theList = parserObj.makelist()
put theList
-- ["ROOT OF XML DOCUMENT": ["!ATTRIBUTES": [:], "sample": ["!ATTRIBUTES": [:]]]]
The following script statements set
element now has a child that contains one space character.
XMLtext = "<sample> </sample>"
parserObj.ignoreWhiteSpace(FALSE)
parserObj.parseString(XMLtext)
theList = parserObj.makelist()
put theList
-- ["ROOT OF XML DOCUMENT": ["!ATTRIBUTES": [:], "sample": ["!ATTRIBUTES": [:], "!CHARDATA":
" "]]]
If there are non-white space characters in a !CHARDATA node, all the characters of the node, including leading and
trailing white space characters, are retained.
XML and character sets
When you use XML, remember that different computer systems use different binary encoding to represent text
characters.
gParserObject
tag). You can get the same information about the root node as for any of the
e1
,
, and
parseString()
method to change the way the Xtra treats white space. If
, white space between elements is treated as actual data.
TRUE
ignoreWhiteSpace()
ignoreWhiteSpace()
variable stores the root of the parsed tree
"ROOT OF XML DOCUMENT"
doneParsing()
.
parseURL()
set to the default
value, and parse the given XML
TRUE
to
, and parse the given XML into a list. The
FALSE
ADOBE DIRECTOR 11.0
User Guide
that
,
,
getError()
is set
ignoreWhiteSpace()
sample
407

Advertisement

Table of Contents
loading

This manual is also suitable for:

Director 11

Table of Contents