UNPKG

woltlab-compiler

Version:

A compiler for WoltLab-Package Archives and WoltLab-Package Components

195 lines (194 loc) 5.32 kB
/** * Provides the functionality to edit xml-files. */ export declare class XMLEditor { /** * The element to edit. */ private element; /** * Initializes a new instance of the `XMLEditor` class. * * @param element * The element to edit. */ constructor(element: Element); /** * Gets the name of the tag of the element. */ readonly TagName: string; /** * Gets the element to edit. */ readonly Element: Element; /** * Gets or sets the text of the element. */ TextContent: string; /** * Gets the parent of the element. */ readonly ParentNode: Node & ParentNode; /** * Gets the document of the element. */ readonly Document: Document; /** * Gets the child-nodes of the element. */ readonly ChildNodes: Node[]; /** * Creates a new element. * * @param tag * The tag of the element to create. * * @param processor * A method for manipulating the new element. */ CreateElement(tag: string, processor?: (element: XMLEditor) => void): XMLEditor; /** * Creates a new element with the specified `textContent` wrapped by a CDATA-section. * * @param tag * The tag of the element to create. * * @param textContent * The text to insert into the element. * * @param processor * A method for manipulating the new element. */ CreateCDATAElement(tag: string, textContent: string, processor?: (element: XMLEditor) => void): XMLEditor; /** * Creates a new element with the specified `textContent`. * * @param tag * The tag of the element to create. * * @param textContent * The text to insert into the element. */ CreateTextElement(tag: string, textContent: string, processor?: (element: XMLEditor) => void): XMLEditor; /** * Adds a new node. * * @param node * The node to add. */ Add<T extends Node | XMLEditor>(node: T, processor?: (node: T) => void): void; /** * Adds a new element. * * @param tag * The tag of the element to create. * * @param processor * A method for manipulating the new element. */ AddElement(tag: string, processor?: (element: XMLEditor) => void): void; /** * Adds a new element with the specified `textContent` wrapped by a CDATA-section. * * @param tag * The tag of the element to create. * * @param textContent * The text to insert into the element. * * @param processor * A method for manipulating the new element. */ AddCDATAElement(tag: string, textContent: string, processor?: (element: XMLEditor) => void): void; /** * Adds a new element with the specified `textContent`. * * @param tag * The tag of the element to create. * * @param textContent * The text to insert into the element. */ AddTextElement(tag: string, textContent: string, processor?: (element: XMLEditor) => void): void; /** * Inserts an element at a specific position. * * @param index * The index to insert the element. * * @param element * The element to insert. */ Insert(index: number, element: XMLEditor | Node): void; /** * Gets all children of the element with a specified tag. * * @param tag * The tag to look for. */ GetChildrenByTag(tag: string): XMLEditor[]; /** * Gets all elements with a specified tag. * * @param tag * The tag to look for. */ GetElementsByTag(tag: string): XMLEditor[]; /** * Gets the text of a child-node. * * @param tag * The tag of the node to get the text. */ GetText(tag: string): string; /** * Gets the value of an attribute. * * @param name * The name of the attribute to get. */ GetAttribute(name: string): string; /** * Sets the value of an attribute. * * @param name * The name of the attribute to set. * * @param value * The value to set. */ SetAttribute(name: string, value: string): void; /** * Gets a value indicating whether an attribute with the specified name exists. * * @param name * The name to look for. */ HasAttribute(name: string, value?: string): boolean; /** * Asserts a tag to contain a text. * * @param text * The text to assert. * * @param tag * The tag to check. */ HasText(tag: string, text: string): boolean; /** * Asserts the element to have a tag. * @param tag * The tag to assert. * * @param unique * A value indicating whether the tag is unique. */ HasTag(tag: string, unique?: boolean): boolean; /** * Converts a node-list to an array. * * @param nodeList * The node-list to convert. */ protected static ToArray<T extends Node>(nodeList: Pick<NodeListOf<T>, "length" | "item">): T[]; }