XMLNSC: Attributes and elements

The XMLNSC parser uses field types to represent attributes and elements.

Use the following field type constants when creating your own syntax elements in the message tree.
Table 1. Specific field type constants
XML Construct XMLNSC Field Type constant Value
Complex element XMLNSC.Folder 0x01000000
Simple element
XMLNSC.Field
XMLNSC.CDataField
0x02000000
0x02000001
Attribute
XMLNSC.SingleAttribute
XMLNSC.Attribute
0x03000100
0x03000101
When accessing elements and attributes in the message tree, use generic field type constants which match all of the alternative values. Because there is only one type of Folder element, it is safe to use XMLNSC.Folder when querying the message tree.
Table 2. Generic field type constants
XML Construct XMLNSC Field Type constant Purpose
Element XMLNSC.Field Matches elements that contain normal text, CData, or a mixture of both
Attribute XMLNSC.Attribute Matches both single-quoted and double-quoted attributes

ESQL code examples

The following examples use this XML message:
<root id="12345">
    <id>ABCDE</id>
</root>
Note that the message contains an attribute and an element with the same name.

Example 1 : Query the value of an XML element

SET value = FIELDVALUE(InputRoot.XMLNSC.root.(XMLNSC.Field)id) 
The result is that value is set to 'ABCDE'.
Example 2 : Query the value of an XML attribute
SET value = FIELDVALUE(InputRoot.XMLNSC.root.(XMLNSC.Attribute)id)
The result is that value is set to '12345'.
Example 3 : Create the example message by using ESQL
CREATE LASTCHILD OF OutputRoot.XMLNSC Type XMLNSC.Folder Name 'root'; 
-- Note : XMLNSC.Attribute could be used here as well. 
SET OutputRoot.XMLNSC.root.(XMLNSC.Attribute)id = '12345'; 
SET OutputRoot.XMLNSC.root.(XMLNSC.Field)id = 'ABCDE';
The first line is optional because the element 'root' is created automatically by the following line if it does not already exist.