---
title: "API de Nodos XML"
description: "Referencia completa de clases, métodos y funciones para XmlNode, XmlNodes, XmlAttributes, importación/exportación y espacios de nombres."
canonical_url: "https://nodecfdi.com/packages/cfdi-core/api-reference/xml-nodes-api"
---

> Index of every page on this site: [llms.txt](https://nodecfdi.com/llms.txt)

Referencia de las clases y funciones del módulo de nodos XML exportadas desde `@nodecfdi/cfdi-core`.

## `XmlNode<TAttributes extends string = string>`

Implementa `XmlNodeInterface<TAttributes>`.

- `constructor(name: string, attributes?: AttributesRecord<TAttributes>, children?: XmlNodeInterface[], value?: string, cdata?: string)`
- `length: number` (getter)
- `name(): string`
- `children(): XmlNodes`
- `addChild(node: XmlNodeInterface): XmlNodeInterface`
- `attributes(): XmlAttributes<TAttributes>`
- `hasAttribute(name: AttributeName<TAttributes>): boolean`
- `setAttribute(name: AttributeName<TAttributes>, value?: string | null): void`
- `getAttribute(name: AttributeName<TAttributes>): string`
- `addAttributes(attributes: AttributesRecord<TAttributes>): void`
- `clear(): void`
- `searchAttribute(...searchPath: string[]): string`
- `searchNodes(...searchPath: string[]): XmlNodes`
- `searchNode(...searchPath: string[]): XmlNodeInterface | undefined`
- `value(): string`
- `setValue(value: string): void`
- `cdata(): string`
- `setCData(cdata: string): void`
- `[Symbol.iterator](): IterableIterator<XmlNodeInterface>`

## `XmlAttributes<TAttributes extends string = string>`

- `constructor(attributes?: AttributesRecord<TAttributes>)`
- `size: number` / `length: number` (getters)
- `get(name: AttributeName<TAttributes>): string`
- `set(name: AttributeName<TAttributes>, value?: string | { toString: () => string } | null): this`
- `delete(name: AttributeName<TAttributes>): boolean`
- `clear(): this`
- `has(name: AttributeName<TAttributes>): boolean`
- `import(attributes: AttributesRecord<TAttributes>): this`
- `export(): Record<string, string>`
- `exportMap(): Map<string, string>`
- `forEach(callbackFn: (value: string, key: string, map: Map<string, string>) => void, thisArgument?: unknown): void`
- `entries(): IterableIterator<[string, string]>`
- `keys(): IterableIterator<string>`
- `values(): IterableIterator<string>`
- `[Symbol.iterator](): IterableIterator<[string, string]>`

## `XmlNodes`

Extiende `Array<XmlNodeInterface>`.

- `constructor(nodes?: XmlNodeInterface[])`
- `add(...nodes: XmlNodeInterface[]): this`
- `delete(node: XmlNodeInterface): this`
- `clear(): this`
- `has(node: XmlNodeInterface): boolean`
- `first(): XmlNodeInterface | undefined`
- `get(position: number): XmlNodeInterface`
- `firstNodeWithName(nodeName: string): XmlNodeInterface | undefined`
- `getNodesByName(nodeName: string): XmlNodes`
- `order(): void`
- `setOrder(names: string[]): void`
- `getOrder(): string[]`
- `importFromArray(nodes: XmlNodeInterface[]): this`

## `XmlNodesSorter`

- `constructor(order?: string[])`
- `setOrder(names: string[]): boolean`
- `parseNames(names: unknown[]): string[]`
- `getOrder(): string[]`
- `sort(nodes: XmlNodeInterface[]): XmlNodeInterface[]`
- `compareNodesByName(a: XmlNodeInterface, b: XmlNodeInterface): number`
- `valueByName(name: string): number`

## Importación y exportación

- `XmlNodeImporter`: `constructor(element: Element)`, `import(): XmlNodeInterface`
- `XmlNodeExporter`: `constructor(node: XmlNodeInterface)`, `export(): Element`
- `nodeToXmlElement(node: XmlNodeInterface): Element`
- `nodeToXmlString(node: XmlNodeInterface, withXmlHeader?: boolean): string`
- `nodeFromXmlElement(element: Element): XmlNodeInterface`
- `nodeFromXmlString(content: string): XmlNodeInterface`

## `NodeNsDefinitionsMover`

- `hasNamespaceFilter(): boolean`
- `getNamespaceFilter(): NamespaceFilter | null`
- `setNamespaceFilter(filter?: NamespaceFilter | null): this`
- `process(root: XmlNodeInterface): void`
- `filterNamespace(namespace: string): boolean`

## Sitemap

See the full [sitemap](https://nodecfdi.com/sitemap.md) for all pages.
