Sims 4 Toolkit - XML DOM (@s4tk/xml-dom)
Overview
This package contains an XML DOM that is tailored for use with Sims 4 tuning files. This XML DOM is general enough to be reused for non-tuning resources, such as ASMs or XML-represented SimData, but is not general enough for uses outside of The Sims 4 modding.
PLEASE NOTE: Proper documentation for this package will be provided when the Sims 4 Toolkit website has been completed. For now, please reference this README's Documentation section, where the TS declaration file stubs are provided.
Installation
Install the package as a dependency from npm with the following command:
npm i @s4tk/xml-dom
Disclaimer
Sims 4 Toolkit (S4TK) is a collection of creator-made modding tools for The Sims 4. "The Sims" is a registered trademark of Electronic Arts, Inc. (EA). Sims 4 Toolkit is not affiliated with or endorsed by EA.
All S4TK software is currently considered to be in its pre-release stage. Use at your own risk, knowing that breaking changes are likely to happen.
Documentation
Index
interface XmlNode
An interface for all XML nodes.
Importing
import type { XmlNode } from "@s4tk/xml-dom";
Properties
get attributes(): Attributes;
get child(): XmlNode;
set child(child: XmlNode);
get children(): XmlNode[];
get hasChildren(): boolean;
get id(): string | number | bigint;
set id(id: string | number | bigint);
get innerValue(): XmlValue;
set innerValue(value: XmlValue);
get name(): string;
set name(name: string);
get numChildren(): number;
get tag(): string;
set tag(tag: string);
get type(): string;
set type(type: string);
get value(): XmlValue;
set value(value: XmlValue);
Methods
addChildren(...children: XmlNode[]): void;
addClones(...children: XmlNode[]): void;
clone(): XmlNode;
deepSort(compareFn?: (a: XmlNode, b: XmlNode) => number): void;
sort(compareFn?: (a: XmlNode, b: XmlNode) => number): void;
toXml(options?: { indents?: number; spacesPerIndent?: number; }): string;
class XmlDocumentNode
A node for an entire XML document. This document can have multiple children, but one is recommended.
See XmlNode for properties and methods.
Importing
import { XmlDocumentNode } from "@s4tk/xml-dom";
const { XmlDocumentNode } = require("@s4tk/xml-dom");
Initialization
constructor(root?: XmlNode);
static from(xml: string | Buffer, options?: {
allowMultipleRoots?: boolean;
ignoreComments?: boolean;
}): XmlDocumentNode;
class XmlElementNode
A node that can have a tag, attributes, and children.
See XmlNode for properties and methods.
Importing
import { XmlElementNode } from "@s4tk/xml-dom";
const { XmlElementNode } = require("@s4tk/xml-dom");
Initialization
constructor(args: {
tag: string;
attributes?: Attributes;
children?: XmlNode[];
});
class XmlValueNode
A node that can have an inner value.
See XmlNode for properties and methods.
Importing
import { XmlValueNode } from "@s4tk/xml-dom";
const { XmlValueNode } = require("@s4tk/xml-dom");
Initialization
constructor(value?: XmlValue);
A node that can have a comment value.
See XmlNode for properties and methods.
Importing
import { XmlCommentNode } from "@s4tk/xml-dom";
const { XmlCommentNode } = require("@s4tk/xml-dom");
Initialization
constructor(value?: string);