Hierarchy

  • XML

Constructors

Methods

  • converts the passed in XML string into a Javascript object

    XML to object deserialisation will use the following rules:

    • element names become property names
    • attributes become properties preceeded by an @ symbol inside the element object
    • element text content is rendered in a special property named keyValue

    Ex:

    <html>
    <image src="./foo/bar/baz.jpg" />
    <hr />
    <span style="color:#808080" class="hidden rounded">
    This is coloured
    </span>
    </html>

    will become:

    {
    "html": {
    "image": {
    "@src": "./foo/bar/baz.jpg",
    },
    "hr": {},
    "span": {
    "@style": "color:#808080",
    "@class": "hidden rounded",
    "keyValue": "This is coloured"
    }
    }
    }

    Type Parameters

    • T extends JsonObject

    Parameters

    • xml: string

      an XML string to be converted into a Javascript object

    Returns T

    a Javascript object representing the passed in XML string

  • converts a passed in XML object into a Javascript object

    XML to object deserialisation will use the following rules:

    • element names become property names
    • attributes become properties preceeded by an @ symbol inside the element object
    • element text content is rendered in a special property named keyValue

    Ex:

    <html>
    <image src="./foo/bar/baz.jpg" />
    <hr />
    <span style="color:#808080" class="hidden rounded">
    This is coloured
    </span>
    </html>

    will become:

    {
    "html": {
    "image": {
    "@src": "./foo/bar/baz.jpg",
    },
    "hr": {},
    "span": {
    "@style": "color:#808080",
    "@class": "hidden rounded",
    "keyValue": "This is coloured"
    }
    }
    }

    Type Parameters

    • T extends JsonObject

    Parameters

    • oXMLParent: Document | Element | DocumentFragment

      an XML Document, Element or DocumentFragment to be converted into a Javascript Object

    Returns T

    a Javascript Object representation of the passed in XML object

Generated using TypeDoc