RosettaCodeData/Task/XML-Output/XPL0/xml-output.xpl0

31 lines
908 B
Plaintext

code ChOut=8, CrLf=9, Text=12;
string 0; \use zero-terminated strings
proc XmlOut(S); \Output string in XML format
char S;
repeat case S(0) of \character entity substitutions
^<: Text(0, "&lt;");
^>: Text(0, "&gt;");
^&: Text(0, "&amp;");
^": Text(0, "&quot;");
^': Text(0, "&apos;")
other ChOut(0, S(0));
S:= S+1;
until S(0) = 0;
int Name, Remark, I;
[Name:= ["April", "Tam O'Shanter", "Emily"];
Remark:= ["Bubbly: I'm > Tam and <= Emily",
"Burns: ^"When chapman billies leave the street ...^"",
"Short & shrift"];
Text(0, "<CharacterRemarks>"); CrLf(0);
for I:= 0 to 3-1 do
[Text(0, " <Character name=^"");
XmlOut(Name(I));
Text(0, "^">");
XmlOut(Remark(I));
Text(0, "</Character>"); CrLf(0);
];
Text(0, "</CharacterRemarks>"); CrLf(0);
]