AllowXmlElement (XmlDoc property)

From m204wiki
Revision as of 17:50, 22 January 2011 by Wiccan (talk | contribs) (1 revision)
Jump to navigation Jump to search

May Element names begin with "xml"? (XmlDoc class)

AllowXmlElement is a member of the XmlDoc class.

This property indicates whether or not the method object XmlDoc allows the deserialization of an XML document that contains Elements that begin with the character sequence xml (regardless of case).

A Boolean value of True allows such deserializations. The default value, False, cancels the request if such a deserialization is attempted.

Syntax

%currentBoolean = doc:AllowXmlElement doc:AllowXmlElement = newBoolean

Syntax terms

%bool The Boolean enumeration value of doc's AllowXmlElement property. For more information about these enumerations, see Using Boolean enumerations.
doc An XmlDoc object expression.

Usage notes

  • Deserializing Elements whose name begins with "xml" was restricted due to the following excerpt from the XML standard:
    • Names beginning with the string "xml", or any string which would match (('X'|'x') ('M'|'m') ('L'|'l')), are reserved for standardization in this or future versions of this specification.

    Therefore, you should use care with element names: using an element name such as XML makes you vulnerable to a change in the standards that would leave your document incompatible with them. Note: This property does not allow the AddElement method to add an element with a name that starts with "xml". However, as shown in "Examples," below, it is easy to use the LoadXml method to accomplish this.

  • The AllowXmlElement method is new in Sirius Mods version 7.3, and it has also been provided by maintenance for version 6.8 and version 7.2.

Examples

  • The following example obtains the string value of the AllowXmlElement property:
        %str = %doc:AllowXmlElement:ToString
    

    Taking advantage of the implicit-ToString feature added in Sirius Mods version 7.3 (see ?? refid=entostr.), you can print this value directly by using this:

        Print %doc:AllowXmlElement
    


  • The following request prints %d:allowXmlElement is True:
        Begin
        %d Object XmlDoc Auto New
        %d:AllowXmlElement = true
        %d:LoadXml('<t>Test<xmlnode></xmlnode></t>')
        PrintText {~} is {%d:allowXmlElement}
        End
    

    Note: Using the PrintText statement is described in ?? refid=prntext.. Printing an enumeration value without a ToString method is described in the first "Note" in ?? refid=crenums..

Request-Cancellation Errors (for set method)

  • %bool is an invalid value.