-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathXmlHelper.h
More file actions
44 lines (33 loc) · 1.27 KB
/
XmlHelper.h
File metadata and controls
44 lines (33 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#ifndef XMLHELPER_H
#define XMLHELPER_H
#include <QDomDocument>
#include "cppXML_global.h"
#include "libxml/xmlerror.h"
///Helper class for XML handling.
class CPPXMLSHARED_EXPORT XmlHelper
{
public:
///Returns an empty string if the xml file is well-formed, or the error message otherwise.
static QString isValidXml(QString xml_file);
///Returns an empty string if the xml file validates against the schema, or the error message otherwise. Throws an Exception if the schema/xml file are not ok.
static QString isValidXml(QString xml_file, QString schema_file);
///Format XML to make it human-readable
static QString format(QString xml);
///Load contents of XML file into DOM datastructure
static QDomDocument load(QString xml_file);
///Parse XML string into DOM datastructure
static QDomDocument parse(QByteArray xml_string);
private:
//declared away
XmlHelper() = delete;
//error handler
static QList<QPair<int, QString>> errors;
#if LIBXML_VERSION >= 21000
static void schemaErrorHandler(void*, const xmlError* error);
static void parseErrorHandler(void *userData, const xmlError* error);
#else
static void schemaErrorHandler(void*, xmlError* error);
static void parseErrorHandler(void *userData, xmlError* error);
#endif
};
#endif