Project

General

Profile

Statistics
| Branch: | Revision:

root / src / nedxml / nedxmlparser.cc @ c87b95b0

History | View | Annotate | Download (1.07 KB)

1
//==========================================================================
2
//  NEDXMLPARSER.CC - part of
3
//
4
//                     OMNeT++/OMNEST
5
//            Discrete System Simulation in C++
6
//
7
//==========================================================================
8

    
9
/*--------------------------------------------------------------*
10
  Copyright (C) 2002-2008 Andras Varga
11
  Copyright (C) 2006-2008 OpenSim Ltd.
12

13
  This file is distributed WITHOUT ANY WARRANTY. See the file
14
  `license' for details on this and other legal matters.
15
*--------------------------------------------------------------*/
16

    
17

    
18
#include "saxparser.h"
19
#include "nedsaxhandler.h"
20
#include "nederror.h"
21
#include "nedxmlparser.h"
22

    
23
NAMESPACE_BEGIN
24

    
25
NEDElement *parseXML(const char *filename, NEDErrorStore *errors)
26
{
27
    NEDSAXHandler sh(filename, errors);
28
    SAXParser parser;
29

    
30
    parser.setHandler(&sh);
31
    bool ok = parser.parse(filename);
32
    if (!ok)
33
    {
34
        errors->addError("", "error reading `%s': %s", filename, parser.getErrorMessage());
35
        return 0;
36
    }
37
    return sh.getTree();
38
}
39

    
40
NAMESPACE_END
41