from xml
for formats> from xml {flags}
--keep-comments, -
: add comment nodes to result--keep-pi, -
: add processing instruction nodes to resultinput | output |
---|---|
string | record |
Converts xml formatted string to record
>'<?xml version="1.0" encoding="UTF-8"?>
<note>
<remember>Event</remember>
</note>'|from xml
╭────────────┬───────────────────────────────────────────────────────────────────────────╮
│tag│note│
│attributes│ {record0fields} │
││╭───┬──────────┬───────────────────┬────────────────────────────────────╮│
│content││# │ tag │ attributes │ content │ │
││├───┼──────────┼───────────────────┼────────────────────────────────────┤│
│││0│remember│ {record0fields} │╭───┬─────┬────────────┬─────────╮││
│││││││# │ tag │ attributes │ content │ │ │
││││││├───┼─────┼────────────┼─────────┤││
│││││││0│││Event│││
││││││╰───┴─────┴────────────┴─────────╯││
││╰───┴──────────┴───────────────────┴────────────────────────────────────╯│
╰────────────┴───────────────────────────────────────────────────────────────────────────╯
Every XML entry is represented via a record with tag, attribute and content fields. To represent different types of entries different values are written to this fields:
{tag: <tag name> attrs: {<attr name>: "<string value>" ...} content: [<entries>]}
{tag: '!' attrs: null content: "<comment string>"}
{tag: '?<pi name>' attrs: null content: "<pi content string>"}
{tag: null attrs: null content: "<text>"}
.Unlike to xml command all null values are always present and text is never represented via plain string. This way content of every tag is always a table and is easier to parse
Copyright © 2019–2023 The Nushell Project DevelopersLicensed under the MIT License.
https://www.nushell.sh/commands/docs/from_xml.html