User Guide
422 Chapter 19: Using the XML Parser Xtra
errCode = gParserObject.parseString(member("XMLtext").text)
theList = gParserObject.makeList()
After this code has been executed, the variable gParserObject contains the parsed node structure
of the XML document, and the variable
theList is a property list that contains all the
information in the document broken into property name and value pairs. All the regular script
methods for sorting and accessing lists can work normally with
theList.
Using XML document nodes
The XML document can contain different types of nodes. Each node can contain different kinds
of data, depending on the node type. You should check the node type before accessing its data so
you know what type of data to expect. Nodes are read-only, so you can retrieve the type, but you
cannot set it.
You use Lingo or JavaScript syntax to access the nodes of an XML document. The following table
shows the script terms that refer to nodes and their properties:
Note: The subfield count exists for any field that is accessible with bracket access. You can specify
whichNode.child.count to find how many children are in the specified node.
Node Script Return value if an element Return value if
text
Return value if
Processing Instruction
type
#element #text #procInst
name
String representing the name of
the element
VOID String representing the
name of the processing
instruction
child[N]
(N is an integer)
The Nth child node of the node;
VOID is returned if no Nth child
exists or there is a script error
VOID VOID
attributeName[N]
(N is an integer)
String representing the name of
the Nth attribute;
VOID is returned if no Nth
attribute exists or there is a
script error
VOID VOID
attributeValue[N]
(N is an integer)
String representing the value of
the Nth attribute;
VOID is returned if no Nth
attribute exists or there is a
script error
VOID VOID
attributeValue[N]
(N is a string)
String representing the value of
the attribute with the name N;
VOID is returned if the node
does not have an attribute
named N or there is a script error
VOID VOID
text
VOID String representing
the character data
contained in this
node
String representing the
data section of the
processing instruction