XML Convert

R←{X}⎕XML Y


Introduction to XML and Glossary of Terms
Conversion from XML
Conversion to XML
Options

⎕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. 
1 Element
2 Child element
4 Character data
8 Markup not otherwise defined
16 Comment markup
32 Processing instruction markup

Example

      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.

Example

      ⎕XML v
<xml> 
  <document id="001">An introduction to XML</document>
</xml>

Introduction to XML and Glossary of Terms
Conversion from XML
Conversion to XML
Options