UNPKG

4.27 kBTypeScriptView Raw
1export declare type Xml = any;
2/**
3 * Given an xml element, returns the value of the attribute with the specified name.
4 * @param xml Xml object
5 * @param name Attribute name
6 * @returns The attribute value or undefined
7 * @example Given the the following xml, the attribute name "DefaultValue" will return the value "abc".
8 * <First DefaultValue="abc">1</First>
9 */
10export declare function getXmlAttributeValue(xml: Xml, name: string): string | undefined;
11/**
12 * Given an xml object, returns the first inner element with the specified name, or undefined.
13 * @param xml Xml object
14 * @param name Element name
15 * @returns Xml object or undefined
16 * @example Given the the following xml, the name "Second" will return the xml object for <Second>...</Second>.
17 * <Current>
18 * <First>1</First>
19 * <Second>2</Second>
20 * </Current>
21 */
22export declare function getXmlElement(xml: Xml, name: string): Xml | undefined;
23/**
24 * Given an xml object, returns the attribute value for the first inner element with the specified name, or undefined.
25 * @param xml Xml object
26 * @param elementName Element name
27 * @param attributeName Attribute name
28 * @example Given the the following xml, the element name "First" and attribute name "DefaultValue" will return the value "abc".
29 * <Current>
30 * <First DefaultValue="abc">1</First>
31 * </Current>
32 */
33export declare function getXmlElementAttributeValue(xml: Xml, elementName: string, attributeName?: string): string | undefined;
34/**
35 * Given an xml object, returns an array with the inner elements with the specified name.
36 * @param xml Xml object
37 * @param name Element name
38 * @returns Array of xml objects;
39 * @example Given the the following xml, the name "Item" will return an array with the two items.
40 * <Items>
41 * <Item>1</Item>
42 * <Item>2</Item>
43 * </Items>
44 */
45export declare function getXmlElements(xml: Xml, name: string): Xml[];
46/**
47 * Given an xml object, for the specified element, returns the values of the inner elements with the specified item element name.
48 * @param xml The xml object.
49 * @param name The name of the inner xml element.
50 * @example Given the the following xml, the container name "Items" and item name "Item" will return ["One", "Two"].
51 * If the attributeName is "AnotherValue", then it will return ["First", "Second"].
52 * <Items>
53 * <Item DefaultValue="One" AnotherValue="First">1</Item>
54 * <Item DefaultValue="Two" AnotherValue="Second">2</Item>
55 * </Current>
56 */
57export declare function getXmlElementsAttributeValue(xml: Xml, name: string, itemElementName: string, attributeName?: string): string[];
58/**
59 * Given an xml object, for the specified element, returns the values of the inner elements with the specified item element name.
60 * @param xml The xml object.
61 * @param name The name of the inner xml element.
62 * @example Given the the following xml, the container name "Items" and item name "Item" will return ["1", "2"].
63 * <Items>
64 * <Item>1</Item>
65 * <Item>2</Item>
66 * </Current>
67 */
68export declare function getXmlElementsValue(xml: Xml, name: string, itemElementName: string): string[];
69/**
70 * Returns the value of the first inner xml element with the specified name.
71 * @param xml The xml object.
72 * @param name The name of the inner xml element.
73 * @example Given the the following xml, the name "Second" will return the value "2".
74 * <Current>
75 * <First>1</First>
76 * <Second>2</Second>
77 * </Current>
78 */
79export declare function getXmlElementValue(xml: Xml, name: string): string | undefined;
80/**
81 * Given an xml object, set the attribute value for the specified element name.
82 * @param xml Xml object
83 * @param elementName Element name
84 * @param attributeValue Attribute value
85 * @param attributeName Attribute name
86 */
87export declare function setXmlElementAttributeValue(xml: Xml, elementName: string, attributeValue: string | undefined, attributeName?: string): void;
88/**
89 * Given an xml object, set the inner xml element
90 * @param xml Xml object
91 * @param elementName Element name
92 * @param elementValue Element value
93 */
94export declare function setXmlElementValue(xml: Xml, elementName: string, elementValue: any): void;