subroutine ParseNextXMLString(
string: XMLString, # The XML string to be parsed
integer: Position, # Position needed to process next tag
string: Tag, # The text of the XML tag
string: String, # Returned string, can be an embedded XML string
boolean: Error) is # Set to true if an XML format error found
string OpenTag_LSV
CloseTag_LSV
Check_LSV
Block_LSV
integer Start_LIV is 1
End_LIV
copy "<" Tag ">" to OpenTag_LSV
copy "</" Tag ">" to CloseTag_LSV
copy false to Error
if (Position < 1) then
copy 1 to Position
end if
extract from XMLString
skip to Position
skip by OpenTag_LSV
if (marker > Position) then
extract from XMLString
skip to marker
take to CloseTag_LSV Block_LSV
take by CloseTag_LSV Check_LSV
if (CloseTag_LSV = Check_LSV) then
copy marker to End_LIV
copy Block_LSV to String
extract from String
skip by OpenTag_LSV
while (marker > Start_LIV) loop
copy marker to Start_LIV
append CloseTag_LSV to String
extract from XMLString
skip to End_LIV
take to CloseTag_LSV Block_LSV
take by CloseTag_LSV Check_LSV
if (CloseTag_LSV = Check_LSV) then
copy marker to End_LIV
append Block_LSV to String
extract from String
skip to Start_LIV
skip by OpenTag_LSV
else
copy true to Error
copy "" to String
leave loop
end if
end loop
# Set the position of the next access
copy End_LIV to Position
else
copy true to Error
copy "" to String
end if
else
# Indicate tag not found by setting Position to zero
copy 0 to Position
copy "" to String
end if