/** * @author Thomas Barnekow * @license MIT */ import { LinqAttributes, LinqElements, Stringifyable, XAttribute, XContainer, XName, XNamespace } from './internal.js'; /** * Represents an XML element. */ export declare class XElement extends XContainer { /** * Gets an empty collection of elements. */ static readonly emptySequence: Iterable; /** * Initializes a new `XElement` instance with the specified name. * * @param name The name of the element. * @param contentArray Zero or more content items. */ constructor(name: XName | string, ...contentArray: any[]); /** * Initializes a new instance of the `XElement` class from another `XElement` object. * * @param other Another element that will be copied to this element. */ constructor(other: XElement); /** * Gets the first attribute of this element. */ get firstAttribute(): XAttribute | null; /** * Gets a value indicating whether the element has at least one attribute. */ get hasAttributes(): boolean; /** * Gets a value indicating whether the element has at least one child element. */ get hasElements(): boolean; /** * Gets a value indicating whether the element contains no content. */ get isEmpty(): boolean; /** * Gets the last attribute of this element. */ get lastAttribute(): XAttribute | null; /** * Gets the name of this element. */ get name(): XName; /** * Sets the name of this element. */ set name(value: XName); /** * Gets the text contents of this element. * * If there is text content interspersed with nodes (mixed content) then the * text content will be concatenated and returned. */ get value(): string; /** * Sets the text content of this element. */ set value(content: string); /** * Returns this `XElement` and all of it's ancestors up to the root node. * Optionally, an `XName` can be passed in to target specific ancestors. * * @param name The optional `XName` of the target ancestor. * @returns An iterable containing this `XElement` and its ancestors (with * a matching `XName` if `name` was provided). */ ancestorsAndSelf(name?: XName | null): LinqElements; /** * Returns the `XAttribute` associated with this `XElement` that has the * given name. * * @param name The `XName` of the `XAttribute` to get. * @returns The `XAttribute` having the given `XName` or `null`. */ attribute(name: XName): XAttribute | null; /** * Gets all attributes associated with this element or the attribute having * the given name. * * @param name The name of the attribute to return. * @returns All attributes associated with this element or the attribute * having the given name. */ attributes(name?: XName | null): LinqAttributes; /** * Gets this `XElement` and the descendant `XElement`s of this `XElement`. * * @param name The optional name of the descendants to return. * @returns This `XElement` and the descendant `XElement`s of this `XElement`. */ descendantsAndSelf(name?: XName | null): LinqElements; /** * Returns the default `XNamespace` of this `XElement`. * * @returns The default `XNamespace` of this `XElement`. */ getDefaultNamespace(): XNamespace; /** * Get the namespace associated with a particular prefix for this `XElement` * in its document context. * * @param prefix The namespace prefix to look up. * @returns The `XNamespace` for the namespace bound to the prefix. * @throws If the prefix is falsy, e.g., the empty string. */ getNamespaceOfPrefix(prefix: string): XNamespace | null; /** * Get the prefix associated with a namespace for an element in its context. * * @param ns The `XNamespace` for which to get the prefix. * @returns The namespace prefix `string`. */ getPrefixOfNamespace(ns: XNamespace): string | null; /** * Creates a new `XElement` instance from the given DOM `Element`. * * @param element The DOM `Element`. * @returns A new `XElement` instance. */ static load(element: Element): XElement; /** * Creates a new `XElement` instance from the given XML string. * * @param text The XML string. * @returns A new `XElement` instance. * @throws An `ArgumentException` if the XML is malformed or does not contain * a root element. */ static parse(text: string): XElement; /** * Removes all nodes and attributes from this `XElement`. */ removeAll(): void; /** * Removes all attributes from this `XElement`. */ removeAttributes(): void; setAttributeValue(name: XName, value: Stringifyable | null): void; toString(): string; }