xml2json
result = xml2json(str)
Input: str · Output: result
What it is
str (string, XML text in xmlify's convention) is converted to JSON. Like csv2json, this produces the same plain array-of-row-objects shape, not jsonify(parse_xml(str))'s type-tagged envelope.
Overloads
One call shape — this function is not overloaded.
| Code | Input | Output | Description |
result = xml2json(str) | str stringnot documented yet | result string | Returns a string. |
Examples
From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.
t = parse_csv("product,price\nWidget,9.99\nGadget,4.50\n")
csv_text = csvify(t)
json_text = jsonify(t)
back_from_json = json2csv(json_text) # csvify(parse_json(json_text))
print(back_from_json)
xml_from_csv = csv2xml(csv_text) # xmlify(parse_csv(csv_text))
csv_from_xml = xml2csv(xml_from_csv) # csvify(parse_xml(xml_from_csv))
print(csv_from_xml)
xml_from_json = json2xml(json_text) # xmlify(parse_json(json_text))
json_from_xml = xml2json(xml_from_json) # the row-object array, not jsonify(parse_xml(...))
parsed = parse_json(json_from_xml) # parse_json accepts that shape too -- back to a real Table
print(nrow(parsed)) # 2
output
product,price Widget,9.99 Gadget,4.5 product,price Widget,9.99 Gadget,4.5 2
from file-io