Time for an 2014 update…
This commit is contained in:
parent
372c577f83
commit
09687c4926
2520 changed files with 34227 additions and 7318 deletions
22
Task/XML-Input/Erlang/xml-input.erl
Normal file
22
Task/XML-Input/Erlang/xml-input.erl
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
-module( xml_input ).
|
||||
|
||||
-export( [task/0] ).
|
||||
|
||||
-include_lib("xmerl/include/xmerl.hrl").
|
||||
|
||||
task() ->
|
||||
{XML, []} = xmerl_scan:string( xml(), [{encoding, "iso-10646-utf-1"}] ),
|
||||
Attributes = lists:flatten( [X || #xmlElement{name='Student', attributes=X} <- XML#xmlElement.content] ),
|
||||
[io:fwrite("~s~n", [X]) || #xmlAttribute{name='Name', value=X} <- Attributes].
|
||||
|
||||
|
||||
|
||||
xml() -> "<Students>
|
||||
<Student Name=\"April\" Gender=\"F\" DateOfBirth=\"1989-01-02\" />
|
||||
<Student Name=\"Bob\" Gender=\"M\" DateOfBirth=\"1990-03-04\" />
|
||||
<Student Name=\"Chad\" Gender=\"M\" DateOfBirth=\"1991-05-06\" />
|
||||
<Student Name=\"Dave\" Gender=\"M\" DateOfBirth=\"1992-07-08\">
|
||||
<Pet Type=\"dog\" Name=\"Rover\" />
|
||||
</Student>
|
||||
<Student DateOfBirth=\"1993-09-10\" Gender=\"F\" Name=\"Émily\" />
|
||||
</Students>".
|
||||
|
|
@ -14,9 +14,8 @@ $$ MODE TUSCRIPT
|
|||
COMPILE
|
||||
LOOP x = xmldata
|
||||
SET name=GET_TAG_NAME (x)
|
||||
IF (name=="student") THEN
|
||||
SET studentname=GET_ATTRIBUTE (x,"Name")
|
||||
IF (studentname!="") PRINT studentname
|
||||
ENDIF
|
||||
IF (name!="student") CYCLE
|
||||
studentname=GET_ATTRIBUTE (x,"Name")
|
||||
IF (studentname!="") PRINT studentname
|
||||
ENDLOOP
|
||||
ENDCOMPILE
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue