xml

package
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 25, 2026 License: MIT Imports: 10 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package xml contains the xml node implementation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type XMLConfig

type XMLConfig struct {
	// Property is the message field to convert; "payload" (default)
	// targets msg.Payload, otherwise a dotted path inside the data map
	Property string `json:"property"`
	// Attr is the object key element attributes are collected under
	// (default "$"); an empty value merges attributes into the element
	// object
	Attr string `json:"attr"`
	// Chr is the object key element text is stored under (default "_")
	Chr string `json:"chr"`
	// Pretty indents marshalled output with two spaces
	Pretty bool `json:"pretty"`
}

XMLConfig holds configuration for the xml node — a Node-RED XML parser equivalent producing xml2js-shaped objects.

type XMLNode

type XMLNode struct {
	*nodebase.BaseNode
	// contains filtered or unexported fields
}

XMLNode converts between an XML string and a generic map form using xml2js conventions:

Parse:   {tag: {"$": {attr: value}, childTag: [values], "_": text}}
Marshal: an object is wrapped in a root element and prefixed with
         the standard XML declaration.

Per-message conversion options can be supplied via msg.options (explicitArray, mergeAttrs, ignoreAttrs, trim, normalize, attrkey, charkey, rootName). Element order is not preserved — payloads are unordered Go maps, so marshalled children emit in sorted order.

func NewXMLNode

func NewXMLNode(node nodestore.NodeInterface, config *XMLConfig) *XMLNode

NewXMLNode creates a new xml node

func (*XMLNode) Execute

Execute reads the configured property, converts it and writes the result back: string → map (parse), map/other → XML string (marshal).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL