Anonymous user
XML/Input: Difference between revisions
m
→{{header|REXX}}: added/changed comments and whitespace, used a template for the output sections.
m (→{{header|REXX}}: added/changed comments and whitespace, used a template for the output sections.) |
|||
Line 2,193:
=={{header|REXX}}==
===version 1===
<lang rexx>/*REXX program
g.=
g.1 = '<Students> '
g.2 = ' <Student Name="April" Gender="F" DateOfBirth="1989-01-02" /> '
g.3 = ' <Student Name="Bob" Gender="M" DateOfBirth="1990-03-04" /> '
g.4 = ' <Student Name="Chad" Gender="M" DateOfBirth="1991-05-06" /> '
g.5 = ' <Student Name="Dave" Gender="M" DateOfBirth="1992-07-08"> '
g.6 = ' <Pet Type="dog" Name="Rover" /> '
g.7 = ' </Student> '
g.8 = ' <Student DateOfBirth="1993-09-10" Gender="F" Name="Émily" /> '
g.9 = '</Students> '
do j=1 while g.j\==''
g.j=space(g.j)
parse var g.j 'Name="' studname '"'
if studname\=='' then say studname
end /*j*/ /*stick a fork in it, we're all done. */</lang>▼
{{out|output|text= when using the default (internal) input:}}
▲ /*stick a fork in it, we're done.*/</lang>
<pre>
April
Line 2,223 ⟶ 2,222:
===version 2===
This REXX version handles more HTML tags for output.
<lang rexx>/*REXX program
g.=
g.1 = '<Students> '
g.2 = ' <Student Name="April" Gender="F" DateOfBirth="1989-01-02" /> '
g.3 = ' <Student Name="Bob" Gender="M" DateOfBirth="1990-03-04" /> '
g.4 = ' <Student Name="Chad" Gender="M" DateOfBirth="1991-05-06" /> '
g.5 = ' <Student Name="Dave" Gender="M" DateOfBirth="1992-07-08"> '
g.6 = ' <Pet Type="dog" Name="Rover" / > '
g.7 = ' </Student> '
g.8 = ' <Student DateOfBirth="1993-09-10" Gender="F" Name="Émily" /> '
g.9 = '</Students> '
do j=1 while g.j\==''
g.j=space(g.j)
parse var g.j 'Name="' studname '"'
if studname=='' then iterate
if pos('&', studname)\==0 then studname=xmlTranE(studname)
say studname
end /*j*/
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
xml_: parse arg ,_ /*
xmlEntity! = '&'_";"
if pos(xmlEntity!,
if left(_, 2)=='#x' then do
xmlEntity!='&'left(_, 3)translate( substr(_, 4) )";"
end
return
/*──────────────────────────────────────────────────────────────────────────────────────*/
xmlTranE: procedure; parse arg
/*the DOS (under Windows) codepage. */
return
Some older REXXes don't have a '''changestr''' BIF, so one is included here ──► [[CHANGESTR.REX]].
{{out|output|text= when using the default (internal) input:}}
<pre>
April
|