diXmlsq
1.0.0
|
The C/C++ interface to diXmlsq.dll which performs simple and full XPath 1.0 queries on an XML document. More...
Macros | |
#define | XMLSQ_ASCIIFY 0x1000 |
Asciify the output as XML character references [default=UTF-8-encoded]. | |
#define | XMLSQ_RAW 0x2000 |
Output nodeset in raw format [default=prettify with tabs and newlines]. | |
#define | XMLSQ_TRIM 0x4000 |
Trim leading and trailing whitespace (and collapse whitespace for an attribute value) | |
#define | XMLSQ__ERR_NOBUFS -1 |
Error: Insufficient buffer space. | |
#define | XMLSQ__ERR_BAD_FILEORXML -2 |
Error: File cannot be opened or is invalid XML. | |
#define | XMLSQ__ERR_BAD_QUERY -3 |
Error: Invalid XPath query. | |
Functions | |
long | XMLSQ_GetText (char *szOut, long nOutChars, const char *xmlFile, const char *query, long nOptions) |
Extract text from the first matching XML node. More... | |
long | XMLSQ_FullQuery (char *szOut, long nOutChars, const char *xmlFile, const char *query, long nOptions) |
Perform a full XPath query on the XML input outputting the result as a string. More... | |
long | XMLSQ_Count (const char *xmlFile, const char *query, long nOptions) |
Compute the count for the XPath query. More... | |
long | XMLSQ_Gen_Version (void) |
Get version number of the core DLL. More... | |
long | XMLSQ_Gen_CompileTime (char *szOut, long nOutChars) |
Get date and time the core DLL module was last compiled. More... | |
long | XMLSQ_Gen_ModuleName (char *szOut, long nOutChars, long nOptions) |
Get full path name of the current process's core library DLL. More... | |
long | XMLSQ_Gen_Platform (char *szOut, long nOutChars) |
Get platform for which the core DLL was compiled ("Win32" or "Win64"). More... | |
The C/C++ interface to diXmlsq.dll which performs simple and full XPath 1.0 queries on an XML document.
szOut
require the buffer to be pre-dimensioned (i.e. allocated) to at least the specified length nOutChars
PLUS one extra for the null-terminating byte. These functions always return the total length in bytes of the string they tried to create (perhaps a negative value if an error). To find the required length, pass a NULL szOut
or zero nOutChars
argument, then add one to the result for the required buffer size.Note that the number returned may be negative if an error occurs. See Error messages.
For example:
query
. XMLSQ_FullQuery() outputs the result of the full XPath 1.0 query as a string.For example, for the file hello-lang.xml
If an error occurs, a negative number -N
is returned.
For XMLSQ_GetText() and XMLSQ_FullQuery() N
is the length of the error message that will be output in the szOut
buffer. You should act on the sign of the return value and allocate the buffer size accordingly. For example.
An error message will begin with **ERROR:
. If the output buffer is too short, XMLSQ__ERR_NOBUFS (-1) will be returned.
For XMLSQ_Count() the error code -N
is either XMLSQ__ERR_BAD_FILEORXML (-2) or XMLSQ__ERR_BAD_QUERY (-3).
long XMLSQ_GetText | ( | char * | szOut, |
long | nOutChars, | ||
const char * | xmlFile, | ||
const char * | query, | ||
long | nOptions | ||
) |
Extract text from the first matching XML node.
szOut | Buffer to receive output. |
nOutChars | Maximum number of character bytes to be received (excluding the null terminating byte). |
xmlFile | Name of XML file or string containing XML data. |
query | XPath 1.0 expression to select a node. This must evaluate to a node or node set. |
nOptions | Option flags. Add with the '|' operator.
|
-N
, where N
is the length of the error message, that will be output in szOut
. If the output buffer szOut
is too short, XMLSQ__ERR_NOBUFS (-1) will be returned. NULL
argument for szOut
or zero for nOutChars
. query
evaluates to a single element with content, then the text content will be output.query
evaluates to an attribute, then the attribute value will be output.query
evaluates to a node set, then the content of the first matching node will be returned as a string, including any markup.long XMLSQ_FullQuery | ( | char * | szOut, |
long | nOutChars, | ||
const char * | xmlFile, | ||
const char * | query, | ||
long | nOptions | ||
) |
Perform a full XPath query on the XML input outputting the result as a string.
szOut | Buffer to receive output. |
nOutChars | Maximum number of character bytes to be received (excluding the null terminating byte). |
xmlFile | Name of XML file or string containing XML data. |
query | XPath 1.0 expression. |
nOptions | Option flags. Add with the '|' operator.
|
-N
, where N
is the length of the error message, that will be output in szOut
. If the output buffer szOut
is too short, XMLSQ__ERR_NOBUFS (-1) will be returned. query
may be any valid XPath 1.0 expression. The result is always output as a string. So, for example, the number 1.5 will be output as the string "1.500000"
and the boolean value true
will be output as "true"
. long XMLSQ_Count | ( | const char * | xmlFile, |
const char * | query, | ||
long | nOptions | ||
) |
Compute the count for the XPath query.
xmlFile | Name of XML file or string containing XML data. |
query | XPath 1.0 expression. This must evaluate to a node or node set. |
nOptions | For future use. Specify zero (0). |
count(query)
or a negative error code. long XMLSQ_Gen_Version | ( | void | ) |
Get version number of the core DLL.
major*10000+minor*100+revision
e.g. DLL file version 1.2.x.3 will return 10203 long XMLSQ_Gen_CompileTime | ( | char * | szOut, |
long | nOutChars | ||
) |
Get date and time the core DLL module was last compiled.
[out] | szOut | Buffer to receive output string. |
[in] | nOutChars | Maximum number of character bytes to be received (excluding the null terminating byte). |
long XMLSQ_Gen_ModuleName | ( | char * | szOut, |
long | nOutChars, | ||
long | nOptions | ||
) |
Get full path name of the current process's core library DLL.
[out] | szOut | Buffer to receive output string. |
[in] | nOutChars | Maximum number of character bytes to be received (excluding the null terminating byte). |
[in] | nOptions | Not used. Specify zero. |
long XMLSQ_Gen_Platform | ( | char * | szOut, |
long | nOutChars | ||
) |
Get platform for which the core DLL was compiled ("Win32" or "Win64").
[out] | szOut | Buffer to receive output string. |
[in] | nOutChars | Maximum number of character bytes to be received (excluding the null terminating byte). |