How Do I Determine the Encoding for an XML Document? (Magic xpa 4.x)

« Go Back


Created BySalesforce Service User
Approval Process StatusPublished

How Do I Determine the Encoding for an XML Document? (Magic xpa 4.x)

The encoding of an XML document can be given in the XML document header (the first line of the XML document), as shown below:

<xml version="1.0" encoding="iso-8859-1"?>

If no encoding is given, utf-8 is assumed. The encoding is used by the parser to determine how to parse the XML; some characters are legal under one encoding but are considered invalid in another.

You don’t need to parse the XML from within Magic xpa to find the encoding, however. There is a function, XMLGetEncoding(), that will fetch it for you.

Using XMLGetEncoding()

The syntax of XMLGetEncoding() is:

XMLGetEncoding(generation, I/O entry)

  • generation is the task’s hierarchic position in the runtime task tree, 0 for the current task, 1 for the parent, and so on.

  • I/O entry is the sequence number of the I/O device that has the XML document.

It returns a text field, which is the value of the “encoding” attribute on the XML document.

See also

The Magic xpa Help utility for XMLGetEncoding and XMLSetEncoding

The Online and Rich Client Samples projects (program XM13 and RXM13)