How to resolve the algorithm XML/Output step by step in the Rascal programming language
How to resolve the algorithm XML/Output step by step in the Rascal programming language
Table of Contents
Problem Statement
Create a function that takes a list of character names and a list of corresponding remarks and returns an XML document of
Let's start with the solution:
Step by Step solution about How to resolve the algorithm XML/Output step by step in the Rascal programming language
Source code in the rascal programming language
import Prelude;
import lang::xml::DOM;
list[str] charnames = ["April", "Tam O\'Shanter", "Emily"];
list[str] remarks = ["Bubbly: I\'m \> Tam and \<= Emily", "Burns: \"When chapman billies leave the street ...\"", "Short & shrift"];
public void xmloutput(list[str] n,list[str] r){
if(size(n) != size(r)){
throw "n and r should be of the same size";
}
else{
characters = [element(none(),"Character",[attribute(none(),"name",n[i]), charData(r[i])]),charData("\n")| i <- [0..size(n)-1]];
x = document(element(none(),"CharacterRemarks",characters));
return println(xmlPretty(x));
}
}
rascal>xmloutput(charnames, remarks)
Bubbly: I'\m > Tam and <= Emily
Burns: "When chapman billies leave the street ..."
Short & shrift
ok
You may also check:How to resolve the algorithm Sorting algorithms/Insertion sort step by step in the Arturo programming language
You may also check:How to resolve the algorithm Hello world/Line printer step by step in the Phix programming language
You may also check:How to resolve the algorithm Fibonacci sequence step by step in the Nial programming language
You may also check:How to resolve the algorithm Ethiopian multiplication step by step in the ALGOL 68 programming language
You may also check:How to resolve the algorithm Execute a system command step by step in the MAXScript programming language