XML/Output: Difference between revisions
Rename Perl 6 -> Raku, alphabetize, minor clean-up
(add task to ARM64 assembly Raspberry Pi) |
Thundergnat (talk | contribs) (Rename Perl 6 -> Raku, alphabetize, minor clean-up) |
||
Line 27:
'''Note to editors:''' Program output with escaped characters will be viewed as the character on the page so you need to 'escape-the-escapes' to make the RC entry display what would be shown in a plain text viewer (See [[Talk:XML_Creation#Escaping_Escapes|this]]).
Alternately, output can be placed in <nowiki><lang xml></lang></nowiki> tags without any special treatment.
=={{header|AArch64 Assembly}}==
{{works with|as|Raspberry Pi 3B version Buster 64 bits}}
Line 197 ⟶ 198:
.include "../includeARM64.inc"
</lang>
=={{header|Ada}}==
{{works with|GNAT}}
Line 355 ⟶ 357:
<Character name="Emily">Short & shrift</Character>
</CharacterRemarks></lang>
=={{header|ARM Assembly}}==
{{works with|as|Raspberry Pi}}
Line 569 ⟶ 572:
CharacterRemarks>
</pre>
=={{header|AutoHotkey}}==
<lang AutoHotkey>gosub constants
Line 855 ⟶ 859:
return EXIT_SUCCESS;
}</lang>
=={{header|C sharp}}==
{{works with|C sharp|C#|3.0+}}
<lang csharp>using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;
class Program
{
static string CreateXML(Dictionary<string, string> characterRemarks)
{
var remarks = characterRemarks.Select(r => new XElement("Character", r.Value, new XAttribute("Name", r.Key)));
var xml = new XElement("CharacterRemarks", remarks);
return xml.ToString();
}
static void Main(string[] args)
{
var characterRemarks = new Dictionary<string, string>
{
{ "April", "Bubbly: I'm > Tam and <= Emily" },
{ "Tam O'Shanter", "Burns: \"When chapman billies leave the street ...\"" },
{ "Emily", "Short & shrift" }
};
string xml = CreateXML(characterRemarks);
Console.WriteLine(xml);
}
}</lang>
Line 904 ⟶ 938:
xmlstring.append( "</CharacterRemarks>" ) ;
return xmlstring ;
}</lang>
Line 1,282 ⟶ 1,286:
\ Output xml string
xml str-get type cr</lang>
=={{header|Go}}==
'''Using package xml to marshal from a data structure:'''
Line 1,586 ⟶ 1,591:
] XMLOutput.
</lang>
=={{header|Julia}}==
Line 2,166 ⟶ 2,170:
}
print $doc->toString();</lang>
=={{header|Phix}}==
Line 2,399 ⟶ 2,384:
</CharacterRemarks>
</lang>
=={{header|Raku}}==
(formerly Perl 6)
{{works with|Rakudo|2018.05}}
<lang perl6>use XML::Writer;
my @students =
[ Q[April], Q[Bubbly: I'm > Tam and <= Emily] ],
[ Q[Tam O'Shanter], Q[Burns: "When chapman billies leave the street ..."] ],
[ Q[Emily], Q[Short & shrift] ]
;
my @lines = map { :Character[:name(.[0]), .[1]] }, @students;
say XML::Writer.serialize( CharacterRemarks => @lines );</lang>
{{out}}
<lang XML><CharacterRemarks><Character name="April">Bubbly: I'm > Tam and <= Emily</Character>
<Character name="Tam O'Shanter">Burns: "When chapman billies leave the street ..."</Character>
<Character name="Emily">Short & shrift</Character></CharacterRemarks></lang>
=={{header|Rascal}}==
Line 2,931 ⟶ 2,936:
<Character name="Tam O'Shanter">Burns: "When chapman billies leave the street..."</Character>
<Character name="Emily">Short &amp; shrift</Character>
</CharacterRemarks>
</pre>
=={{header|XPL0}}==
<lang XPL0>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, "<");
^>: Text(0, ">");
^&: Text(0, "&");
^": Text(0, """);
^': Text(0, "'")
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);
]</lang>
{{out}}
<pre>
<CharacterRemarks>
<Character name="April">Bubbly: I'm > Tam and <= Emily</Character>
<Character name="Tam O'Shanter">Burns: "When chapman billies leave the street ..."</Character>
<Character name="Emily">Short & shrift</Character>
</CharacterRemarks>
</pre>
Line 3,011 ⟶ 3,057:
</CharacterRemarks>
</lang>
=={{header|Yabasic}}==
|