diff options
Diffstat (limited to 'src/modules/xml/xmlApi.cpp')
-rw-r--r-- | src/modules/xml/xmlApi.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/modules/xml/xmlApi.cpp b/src/modules/xml/xmlApi.cpp index 2335b7c6d7..113f2e9ecd 100644 --- a/src/modules/xml/xmlApi.cpp +++ b/src/modules/xml/xmlApi.cpp @@ -37,6 +37,19 @@ static void xmlapiDestroyNode(HXML n) XMLNode tmp; tmp.attach(n);
}
+static HXML xmlapiParseFile(LPCTSTR str, int* datalen, LPCTSTR tag)
+{
+ if (str == NULL) return NULL;
+
+ XMLResults res;
+ XMLNode result = XMLNode::parseFile(str, tag, &res);
+
+ if (datalen != NULL)
+ datalen[0] += res.nChars;
+
+ return (res.error == eXMLErrorNone || (tag != NULL && res.error == eXMLErrorMissingEndTag)) ? result.detach() : NULL;
+}
+
static HXML xmlapiParseString(LPCTSTR str, int* datalen, LPCTSTR tag)
{
if (str == NULL) return NULL;
@@ -155,6 +168,11 @@ static LPTSTR xmlapiToString(HXML _n, int* datalen) return XMLNode(_n).createXMLString(0, datalen);
}
+static XMLError xmlapiToFile(HXML _n, LPCTSTR filename)
+{
+ return XMLNode(_n).writeToFile(filename, NULL, NULL);
+}
+
static void xmlapiAddAttr(HXML _n, LPCTSTR attrName, LPCTSTR attrValue)
{
if (attrName != NULL && attrValue != NULL)
@@ -382,6 +400,8 @@ static INT_PTR GetXmlApi(WPARAM, LPARAM lParam) xi->parseString = xmlapiParseString;
xi->toString = xmlapiToString;
xi->freeMem = xmlapiFree;
+ xi->parseFile = xmlapiParseFile;
+ xi->toFile = xmlapiToFile;
xi->addChild = xmlapiAddChild;
xi->addChild2 = xmlapiAddChild2;
|