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 ¶
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 ¶
func (n *XMLNode) Execute(ctx context.Context, input nodestore.MessageInterface) (nodestore.MessageInterface, error)
Execute reads the configured property, converts it and writes the result back: string → map (parse), map/other → XML string (marshal).