⎕XML converts an XML string into an APL array or converts an APL array into an XML string.
The optional left argument X specifies a set of option/value pairs, each of which is a character vector. X may be a 2-element vector, or a vector of 2-element character vectors.
For conversion from XML, Y is a character vector containing an XML string. The result R is a 5 column matrix whose columns are made up as follows:
| Col | Description | |||||||||||||
| 1 | Numeric value which indicates the level of nesting. | |||||||||||||
| 2 | Element name, other markup text, or empty character vector when empty. | |||||||||||||
| 3 | Character data or empty character vector when empty. | |||||||||||||
| 4 | Attribute name and value pairs, (0 2⍴⊂'') when empty. | |||||||||||||
| 5 | A numeric value which indicates what the row contains. |
|
||||||||||||
x←'<xml><document id="001">An introduction to XML'
x,←'</document></xml>'
]display v←⎕XML x
┌→───────────────────────────────────────────────────────┐
↓ ┌→──┐ ┌⊖┐ ┌→────────┐ │
│ 0 │xml│ │ │ ⌽ ┌⊖┐ ┌⊖┐ │ 3 │
│ └───┘ └─┘ │ │ │ │ │ │ │
│ │ └─┘ └─┘ │ │
│ └∊────────┘ │
│ ┌→───────┐ ┌→─────────────────────┐ ┌→───────────┐ │
│ 1 │document│ │An introduction to XML│ ↓ ┌→─┐ ┌→──┐ │ 5 │
│ └────────┘ └──────────────────────┘ │ │id│ │001│ │ │
│ │ └──┘ └───┘ │ │
│ └∊───────────┘ │
└∊───────────────────────────────────────────────────────┘
For conversion to XML, Y is a 3, 4 or 5 column matrix and the result R is a character vector. The columns of Y have the same meaning as those described above for the result of converting from XML.
⎕XML v <xml> <document id="001">An introduction to XML</document> </xml>