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.
You can use the
ignoreWhiteSpace()
setting the
ignoreWhiteSpace()
Xtra to treat instances of white space as literal data nodes. This way, white space between elements
is treated as actual data.
The following Lingo statements leave
parse the given XML into a list. The
XMLtext = "<sample> </sample>"
parserObj.parseString(XMLtext)
theList = parserObj.makelist()
put theList
-- ["ROOT OF XML DOCUMENT": ["!ATTRIBUTES": [:], "sample": ["!ATTRIBUTES":
[:]]]]
The following Lingo statements set
into a list. The
sample
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.
The XML Parser Xtra adheres strictly to the XML specification, which states that XML
documents are, by default, encoded using the UTF-8 character set. If the document is
not encoded in UTF-8, it must include a declaration of its character set in the first line of
the document.
The following XML declares the IOS-8859-1 character set, also known as Latin1:
<?xml version="1.0" encoding="ISO-8859-1" ?>
This requirement applies to documents parsed by
by
.
parseURL()
function to change the way the Xtra treats white space. By
to
instead of its default value of
FALSE
ignoreWhiteSpace()
element has no children in the list.
sample
ignoreWhiteSpace()
element now has a child that contains one space character.
set to the default
to
, and parse the given XML
FALSE
as well as files that are parsed
parseString()
Using the XML Parser Xtra 549
, you can tell the
TRUE
value, and
TRUE
Need help?
Do you have a question about the DIRECTOR MX-USING DIRECTOR MX and is the answer not in the manual?
Questions and answers