Dear All,
While working on XML import using batch process requirement i came across an ERROR using the following sample code, the code works fine if it is not run as a batch process…Please help
Error:
Request for the permission of type ‘FileIOPermission’ failed.
(S)\Classes\FileIOPermission\demand
(S)\Classes\XmlDocument\newFile
(S)\Classes\ReadingXMLFile\run - line 4
(S)\Classes\BatchRun\runJobStatic - line 63
Code:
public void run()
{
XMLDocument XMLdoc = XMLDocument::newFile(@“D:\Items.xml”);
int i,CountItemtags;
K_Xml x; // table buffer
FileIOPermission fileIOPerm;
;
fileIOPerm = new FileIOPermission(@“D:\Items.xml”,“r”);
fileIOPerm.assert();
XMLdoc.loadXml(XMLdoc.toString());
countItemTags = xmldoc.getElementsByTagName(‘AccountNum’).length();
info (strfmt(‘Number of tags with name Item - %1’, countItemTags));
for (i = 0 ; i < countItemTags; i++)
{
x.AccountNum = xmldoc.getElementsByTagName(‘AccountNum’).item(i).text();
x.AccountName = xmldoc.getElementsByTagName(‘AccountName’).item(i).text();
x.insert();
}
}
Regards,
kaushik