XMLGenericQuery





http://www.QuantTools.com
CapeTools Utils function list

Welcome | Documentation format | QuantTools Groups | QuantTools Categories | Licence

Key TAGs | Excel Index | API Index



Queries a generic XML document, with the given XPath query.

If the results are simple native types : integer, long, double or string values (including arrays of these native types) the results will be returned within a range object.

If the result ends up as a XML node-set (a mini XML file) the name(s) of the XML element(s) will be returned.

As your queries can get quite large and complex, there are 4 additional, but optional, parameters that you can use to extend your XPath queries.

Your final query will simply be the concatenation of all 5 XPath parameters.

The additional ranges are needed as Excel has a limit of 255 characters per string parameter entered.

(Excel functions only).



Note: Within Excel, the function is named - CT.XML.GenericQuery




High level graphic of XMLGenericQuery() function with parameters. Blue square node is the actual function with the parameters ordered.



Parameter Description


  1. XMLDocKey parameter

    Key to an already loaded XML document ( via a call to the ReadXML() function )
  2. XPathQuery parameter

    The query you would like to perform.
  3. XPathQuery2 parameter

    Additional parameter to extend your XPath query. Will be appended to the end of the previous XPath expression.
  4. XPathQuery3 parameter

    Additional parameter to extend your XPath query. Will be appended to the end of the previous XPath expression.
  5. XPathQuery4 parameter

    Additional parameter to extend your XPath query. Will be appended to the end of the previous XPath expression.
  6. XPathQuery5 parameter

    Additional parameter to extend your XPath query. Will be appended to the end of the previous XPath expression.


Extended information

Function Syntax

VB Syntax


Variant CTUtils.XMLGenericQuery( _
String XMLDocKey, _
String XPathQuery, _
String XPathQuery2, _
String XPathQuery3, _
String XPathQuery4, _
String XPathQuery5)


Excel Spreadsheet Syntax


=CT.XML.GenericQuery(
Excel String Cell XMLDocKey,
Excel String Cell XPathQuery,
Excel String Cell XPathQuery2,
Excel String Cell XPathQuery3,
Excel String Cell XPathQuery4,
Excel String Cell XPathQuery5)


C++ Syntax


static CTRangeDataCPP XMLGenericQuery(
std::string XMLDocKey,
std::string XPathQuery,
std::string XPathQuery2,
std::string XPathQuery3,
std::string XPathQuery4,
std::string XPathQuery5);


DotNET Syntax


CTRangeData CTUtilsSA.XMLGenericQuery(
System.String XMLDocKey,
System.String XPathQuery,
System.String XPathQuery2,
System.String XPathQuery3,
System.String XPathQuery4,
System.String XPathQuery5);

Parameter data types

ArgNameArgTypeIsKey
XMLDocKeyStringTRUE
XPathQueryStringFALSE
XPathQuery2StringFALSE
XPathQuery3StringFALSE
XPathQuery4StringFALSE
XPathQuery5StringFALSE


Example Inputs

The first column represents the name of the parameters. The second column specifies whether the parameters are optional or not. Finally the last column provides some sample input data.
Function call input string-keys are always in the format : "NAME.EXTTAG.TICKER" The "EXTTAG.TICKER" part is determined from the output of other, capetools, object creation functions.


ArgNameIsOptional (Excel only)Example
XMLDocKeyFALSEXMLDocKeyNAME.EXTTAG.TICKER (from a function call)
XPathQueryFALSE/FpML/trade[1]/swap[1]/swapStream[1]/calculationPeriodDates[1]/calculationPeriodFrequency[1]/period/text()
XPathQuery2TRUE
XPathQuery3TRUE
XPathQuery4TRUE
XPathQuery5TRUE


Example function usage


The C# example below contains all the sub-function calls leading up to this function call. As a result, the example can contain a lot of code.

The VB.NET, J#, C++.NET, Java, Excel VBA, Visual Basic 6 (via COM) and C++ examples below contain function code stubs for the calls leading up to this function call. However, the function call for this function is displayed.
You can easily reproduce the stub functions code from the C# example.


If you are accessing this functrion via the MiniXL libraries, this function is present within the CT.QL.Utils20 MiniXL Excel Addin.

Within our Excel Example Addin Generator, we have used the following QuantTools sub-functions in order to prepare the arguments needed to call the XMLGenericQuery() function. If you are executing this function via the MiniXL libraries, the module addin name, (in brackets, to the right of the sub-functions listed below), indicates the MiniXL library in which the sub-function is held. You will need to load this library into your Excel session (along with any other libraries that the sub-function call within the addin requires (ie - CT.QT.Utils20 addin in almost all cases) in order for the example to compute successfully.

These are the financial QuantTools sub-function calls that are used within the examples :





The objects generated by these sub-functions are inter-connected in the following way :




The following four examples demostrate calling this function within a Microsoft .NET environment

The following four examples demostrate calling this function within a non .NET environment

Copyright (c) 2003-2007 CapeTools - All Rights Reserved.