Module: 'brixy.es.typedXML'

Methods for converting ExtendScript value to typed XML and vice versa.

Typed XML uses a special set of the tags. Optional "name" attribute defines the name of the equivalent ExtendScript Object's property.

Supported ES types and equivalent XML tags:

ExtendScript type Typed XML tag
string string
number number
boolean boolean
Object object
Array array
XML objectXml
undefined undefined

Note: This module doesn't use E4X because E4X doesn't use a pure javascript syntax. This improves compatibility with other javascript tools, eg. minifiers.

Example:

It will convert this object:

{
    city: {
        name: 'Prague',
        GPS: {N: 50.0904317, E: 14.4000508},
        population: 1250000,
        beautiful: true,
        disneyland: undefined
    },
    colors: ['red', 'green', 'blue', ['black', 'white']],
    myXml: new XML('<abc><a>A</a><b>B</b><c>C</c></abc>')
}

to this XML:

<object>
    <object name="city">
        <string name="name">Prague</string>
        <object name="GPS">
            <number name="N">50.0904317</number>
            <number name="E">14.4000508</number>
        </object>
        <number name="population">1250000</number>
        <boolean name="beautiful">true</boolean>
        <undefined name="disneyland"></undefined>
    </object>
    <array name="colors">
        <string>red</string>
        <string>green</string>
        <string>blue</string>
        <array>
            <string>black</string>
            <string>white</string>
        </array>
    </array>
    <objectXml name="myXml">
        <abc>
            <a>A</a>
            <b>B</b>
            <c>C</c>
        </abc>
    </objectXml>
</object>

and vice versa.

Methods

(static) valueToXml (val, nameopt, depthopt) → {XML}

Converts ExtendScript value to typed XML.

Parameters:
Name Type Attributes Description
val *

Value.

name string <optional>

Name attribute of the XML element. (optional)

depth string <optional>

Level of nesting. (optional)

Returns:
  • XML
Source:

(static) xmlToValue (xml) → {*}

Converts a typed XML to ExtendScript value.

Parameters:
Name Type Description
xml XML

Typed XML object.

Returns:
  • *
Source: