46 lines
1.4 KiB
Plaintext
46 lines
1.4 KiB
Plaintext
code ChOut=8, CrLf=9; \intrinsic routines
|
|
string 0; \use zero-terminated strings
|
|
|
|
func StrLen(A); \Return number of characters in an ASCIIZ string
|
|
char A;
|
|
int I;
|
|
for I:= 0 to -1>>1-1 do
|
|
if A(I) = 0 then return I;
|
|
|
|
func StrFind(A, B); \Search for ASCIIZ string A in string B
|
|
\Returns address of first occurrence of string A in B, or zero if A is not found
|
|
char A, B; \strings to be compared
|
|
int LA, LB, I, J;
|
|
[LA:= StrLen(A);
|
|
LB:= StrLen(B);
|
|
for I:= 0 to LB-LA do
|
|
[for J:= 0 to LA-1 do
|
|
if A(J) # B(J+I) then J:= LA+1;
|
|
if J = LA then return B+I; \found
|
|
];
|
|
return 0;
|
|
];
|
|
|
|
char XML, P;
|
|
[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>";
|
|
P:= XML;
|
|
loop [P:= StrFind("<Student ", P);
|
|
if P=0 then quit;
|
|
P:= StrFind("Name=", P);
|
|
if P=0 then quit;
|
|
P:= P + StrLen("Name=x");
|
|
repeat ChOut(0, P(0));
|
|
P:= P+1;
|
|
until P(0) = ^";
|
|
CrLf(0);
|
|
];
|
|
]
|