Sorry I’m new to C#. Trying to retrieve information from the following XML code with the “AccountFunds” routine below. There is a class that is drived from the API XSD file, in here “accountSnapshot.availableToBetBalance” is declared as a double.
The code line “accountSnapshot.availableToBetBalance = nodeList.Item(0).InnerXml;” raises a Error “Cannot implicitly convert type 'string' to 'double'”.
Ive tryed this line “accountSnapshot.availableToBetBalance = ((double)(nodeList.Item(0).InnerXml));” but this gives rise to a “Cannot convert type 'string' to 'double'”
How do you convert the “nodeList.Item(0).InnerXml” so that it is a double.
Is the “AccountFunds” routine the logical way to extract the XML code.
The XML code
< xml version="1.0" encoding="UTF-8" standalone="yes" >
< xml-stylesheet type="text/xsl" href="/rest/apiStylesheet.xsl" >
<accountSnapshot currency="GBP" xmlns="https://api.betfairgames.com/rest/v1">
<exposureLimit>-5000.0</exposureLimit>
<availableToBetBalance>14.87</availableToBetBalance>
<availableToTransferOut>14.8799999999999</availableToTransferOut>
<betfairGamesBalance>25.76</betfairGamesBalance>
<currentExposure>-10.88</currentExposure>
<retainedCommission>0.0</retainedCommission>
</accountSnapshot>
public void AccountFunds(Account account)
{
HttpAccountRequest request = new HttpAccountRequest();
request.Method = "Get";
request.Account = account;
//Execute the request and get the response
HttpAccountResponse response = request.GetResponse();
localresponse = response.ToString();
XmlDocument XMLdoc = new XmlDocument();
XMLdoc.LoadXml(localresponse);
XmlElement RootNode = XMLdoc.DocumentElement;
XmlNodeList nodeList = RootNode.GetElementsByTagName("availableToBetBalance");
accountSnapshot.availableToBetBalance = nodeList.Item(0).InnerXml;
//accountSnapshot.availableToBetBalance = ((double)(nodeList.Item(0).InnerXml));
response.Close();
}