UNPKG

@manuth/woltlab-compiler

Version:

A compiler for generating WoltLab-Package `.tar` Archives and other WoltLab-Package Components

164 lines (163 loc) 4.05 kB
/** * Provides the functionality to edit xml-files. */ export declare class XMLEditor { /** * The element to edit. */ private element; /** * Initializes a new instance of the {@link XMLEditor `XMLEditor`} class. * * @param element * The element to edit. */ constructor(element: Element); /** * Gets the name of the tag of the element. */ get TagName(): string; /** * Gets the element to edit. */ get Element(): Element; /** * Gets or sets the text of the element. */ get TextContent(): string; /** * @inheritdoc */ set TextContent(value: string); /** * Gets the parent of the element. */ get ParentNode(): Node & ParentNode; /** * Gets the document of the element. */ get Document(): Document; /** * Gets the child-nodes of the element. */ get ChildNodes(): Node[]; /** * Creates a new element. * * @param tag * The tag of the element to create. * * @returns * The editor for the newly created element. */ CreateElement(tag: string): XMLEditor; /** * Creates a new element with the specified {@link textContent `textContent`} wrapped by a CDATA-section. * * @param tag * The tag of the element to create. * * @param textContent * The text to insert into the element. * * @returns * The editor for the newly created element. */ CreateCDATAElement(tag: string, textContent: string): XMLEditor; /** * Creates a new element with the specified {@link textContent `textContent`}. * * @param tag * The tag of the element to create. * * @param textContent * The text to insert into the element. * * @returns * The editor for the newly created element. */ CreateTextElement(tag: string, textContent: string): XMLEditor; /** * Adds a node. * * @template T * The type of the node to add. * * @param node * The node to add. */ Add<T extends Node | XMLEditor>(node: T): 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. * * @returns * The xml-editor of the children which were found. */ GetChildrenByTag(tag: string): XMLEditor[]; /** * Gets all elements with a specified tag. * * @param tag * The tag to look for. * * @returns * The xml-editor of the children which were found. */ GetElementsByTag(tag: string): XMLEditor[]; /** * Gets the value of an attribute. * * @param name * The name of the attribute to get. * * @returns * The value of the attribute. */ 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. * * @returns * A value indicating whether an attribute with the specified {@link name `name`} exists. */ HasAttribute(name: string): boolean; /** * Converts a node-list to an array. * * @param nodeList * The node-list to convert. * * @template T * The type of the nodes. * * @returns * An array representing the specified {@link nodeList `nodeList`}. */ protected static ToArray<T extends Node>(nodeList: Pick<NodeListOf<T>, "length" | "item">): T[]; }