Тема: Read XML file
Показать сообщение отдельно
Старый 16.06.2008, 16:01   #5  
konopello is offline
konopello
SAP
SAP
 
628 / 76 (4) ++++
Регистрация: 08.11.2005
Адрес: Минск
Всем спасибо, проблему решил
X++:
static str OEMToCharBuff(str _strSource)
{
    DLL         winApiDLL = new DLL('USER32');
    DLLFunction OEMToChar = new DLLFunction(winApiDLL, 'OemToCharA');
    Binary      bSource   = new Binary(_strSource);
    str         oemstr;
    ;

    OEMToChar.returns(ExtTypes::DWORD);
    OEMToChar.arg(ExtTypes::POINTER, ExtTypes::POINTER);
    OEMToChar.call(bSource, bSource);
    oemstr = bSource.string(0);

    return oemstr;
}
X++:
static void A000088_WorkXML(Args _args)
{
    TextBuffer                  textBuffer;

    XmlDocument                 xmlDoc;
    XMLNodeList                 tests;
    XMLNode                     node;
    XMLParseError               error;
    XmlProcessingInstruction    xmlProcessingInstruction;

    FileIOPermission    sourceFileReadPerm;

    Filename            sourceFileName = 'C:\\Tmp\\101.xml';

    #define.read('R')
    #define.write('W')
    ;

    // Assert permission to use XML save
    sourceFileReadPerm = new FileIOPermission(sourceFileName, #read);
    sourceFileReadPerm.assert();

    textBuffer = new TextBuffer();
    textBuffer.fromFile(sourceFileName);
    textBuffer.setText(WinApi::OEMToCharBuff(textBuffer.getText())); // А ВОТ И ПЕРЕВОД

    xmlDoc = new XmlDocument();

    if (!xmlDoc.loadXML(textBuffer.getText()))
    {
        error = xmlDoc.parseError();
        info("Error during load of XML: " + error.reason() + " in line " + int2str(error.line()));
        return;
    }

    tests = xmlDoc.selectNodes('//Statements');

    node = tests.nextNode();
    while (node)
    {
        info(node.selectSingleNode('Date').text());
        info(node.selectSingleNode('Account').text());
        node = tests.nextNode();
    }
}