delphi - "A call to an OS function failed" when loading Windows-1252 XML file -
edit:
the error indeed in handling; parseerror fails ans reveals real error; see follow-up question error.
old question:
somehow, code below generates exception when loading xml using msxml unit in delphi xe. fails on windows xp professional x86 sp3 using msxml6 , windows 7 ultimate x64 sp1 using msxml6.
procedure txmleoserrortestcase.test; var xmldocument: ixmldomdocument3; xmlfilename: string; begin xmldocument := cofreethreadeddomdocument60.create(); xmlfilename := tpath.combine(tpath.getdirectoryname(paramstr(0)), '1-normal.xml'); if not xmldocument.load(xmlfilename) raiselastoserror(); end; this error occurs during xmldocument.load method:
eoserror @ $00423b2d call os function failed i trimmed xml down xml found below.
this hex dump of xml file:
000000: 3c 3f 78 6d 6c 20 76 65 72 73 69 6f 6e 20 3d 20 <?xml version = 000010: 22 31 2e 30 22 20 65 6e 63 6f 64 69 6e 67 3d 22 "1.0" encoding=" 000020: 57 69 6e 64 6f 77 73 2d 31 32 35 32 22 3f 3e 3c windows-1252"?>< 000030: 52 4f 57 20 43 69 74 79 3d 22 e0 22 2f 3e 0d 0a row city="."/>.. this xml:
<?xml version = "1.0" encoding="windows-1252"?><row city="à"/> why error occur?
(the xml loads fine in .net , other environments not using msxml6).
--jeroen
as can see in sysutils.pas, error message 1 that's given when getlasterror returns zero. documentation ixmldomdocument.load not advise call getlasterror discover reason failure. last-error value thread default 0 value.
instead, inspect document object's parseerror value. give ixmldomparseerror object tells , why problem occurred.
Comments
Post a Comment