User Guide
parseURL() 441
The movie script contains the on parseDone handler:
on parseDone
global gParserObject
if voidP(gParserObject.getError()) then
put "Successful parse"
else
put "Parse error:"
put " " & gParserObject.getError()
end if
end
This JavaScript syntax parses the file sample.xml and calls the parseDone function. Because no
script object is given with the
doneParsing() function, the parseDone function is assumed to be
in a movie script.
errorCode = _global.gParserObject.parseURL("http://- www.MyCompany.com/
sample.xml", symbol("parseDone"));
Note: This example supposes that an instance of the Xtra has already been created, and a reference
to that has been stored in the global variable named gParserObject.
The movie script contains the on parseDone handler:
// JavaScript syntax
function parseDone () {
if (_global.gParserObject.getError() == undefined) {
trace("successful parse");
} else {
trace("Parse error:");
trace(" " + _global.gParserObject.getError());
}
}
This Lingo parses the document sample.xml at MyCompany.com and calls the on parseDone
handler in the script object
testObject, which is a child of the parent script TestScript:
parserObject = new(xtra "XMLParser")
testObject = new(script "TestScript", parserObject)
errorCode = gParserObject.parseURL("http://www.MyCompany.com/sample.xml",
#parseDone, testObject)
Here is the parent script TestScript:
property myParserObject
on new me, parserObject
myParserObject = parserObject
end
on parseDone me
if voidP(myParserObject.getError()) then
put "Successful parse"
else
put "Parse error:"
put " " & myParserObject.getError()
end if
end