UNPKG

aft-web-services

Version:

Automated Functional Testing (AFT) module for testing web services over HTTP and HTTPS

84 lines (83 loc) 2.71 kB
import { JsonObject } from "aft-core"; export declare class XML { /** * 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:* * ```xml * <html> * <image src="./foo/bar/baz.jpg" /> * <hr /> * <span style="color:#808080" class="hidden rounded"> * This is coloured * </span> * </html> * ``` * will become: * ```json * { * "html": { * "image": { * "@src": "./foo/bar/baz.jpg", * }, * "hr": {}, * "span": { * "@style": "color:#808080", * "@class": "hidden rounded", * "keyValue": "This is coloured" * } * } * } * ``` * @param oXMLParent an XML Document, Element or DocumentFragment to be converted * into a Javascript Object * @returns a Javascript Object representation of the passed in XML object */ static toObject<T extends JsonObject>(oXMLParent: Document | Element | DocumentFragment): T; /** * 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:* * ```xml * <html> * <image src="./foo/bar/baz.jpg" /> * <hr /> * <span style="color:#808080" class="hidden rounded"> * This is coloured * </span> * </html> * ``` * will become: * ```json * { * "html": { * "image": { * "@src": "./foo/bar/baz.jpg", * }, * "hr": {}, * "span": { * "@style": "color:#808080", * "@class": "hidden rounded", * "keyValue": "This is coloured" * } * } * } * ``` * @param xml an XML string to be converted into a Javascript object * @returns a Javascript object representing the passed in XML string */ static fromString<T extends JsonObject>(xml: string): T; private static _parseText; private static _fromXmlNode; private static _fromElement; }