IronFlowDocs

xml_stringify

Convert a JSON value from context into an XML string.

Parameters

source_keystringrequired
Context key containing the JSON value to convert.
output_keystringdefault "xml"
Context key for the XML string output.
root_tagstringdefault "root"
Tag name for the root XML element.
prettybooleandefault false
Whether to indent the output XML.

Context Output

  • <output_key> (default xml) — the generated XML string.

JSON to XML Mapping

  • Object keys become XML element tags.
  • Keys prefixed with @ become XML attributes on the parent element.
  • The #text key becomes text content of the parent element.
  • Arrays produce repeated elements with the same tag name.
  • Strings, numbers, and booleans become text content.
  • Null values produce self-closing elements.

Example

local flow = Flow.new("stringify_xml")

flow:step("build", nodes.code({
    source = [[
        ctx.catalog = {
            book = {
                ["@id"] = "1",
                title = "Rust in Action",
                price = "39.99"
            }
        }
    ]]
}))

flow:step("stringify", nodes.xml_stringify({
    source_key = "catalog",
    root_tag = "catalog",
    pretty = true
})):depends_on("build")

flow:step("done", nodes.log({
    message = "Generated XML: ${ctx.xml}"
})):depends_on("stringify")

return flow

IronFlow documentation

Find the next step

Type a keyword to search the documentation.

to move · Enter to open · Esc to close