XML/Input: Difference between revisions

→‎{{header|Bracmat}}: Had overseen Dave, added explaining text
m (→‎{{header|Bracmat}}: typo corrected)
(→‎{{header|Bracmat}}: Had overseen Dave, added explaining text)
Line 416:
</pre>
=={{header|Bracmat}}==
The <code>get</code> function can read markup into a native datastructure, which can be analysed using pattern matching.
Read input from file:
The read datastructure is a flat list of tags and text fragments. For proper nesting of elements extra code would have to be written, but in this simple task that is not necessary. On the downside, the pattern must both handle empty tags (the <code>(? (Name.?name) ?,</code> pattern) and open tags (the <code>? (Name.?name) ?</code> pattern).
ReadReading input from a file:
<lang bracmat>( :?names
& ( get$("students.xml",X,ML)
: ?
( ( Student.? (Name.?name) ?,)
. (? (Name.?name) ?,)
| ? (Name.?name) ?
)
& !names !name:?names
& ~
Line 446 ⟶ 451:
)
: ?
( ( Student.? (Name.?name) ?,)
. (? (Name.?name) ?,)
| ? (Name.?name) ?
)
& !names !name:?names
& ~
Line 455 ⟶ 463:
)</lang>
Output:
<pre>April Bob Chad Dave Émily</pre>
 
=={{header|C}}==
483

edits