// // Disclaimer: // // DTN grants you an nonexclusive copyright license to use this code and you can // use it to prepare similar functions tailored to your own needs. // // The code is provided for illustrative purposes only and has not been tested under // all conditions. For that reason, DTN provides this code to you "AS IS" without // any warranties of any kind. // import com.telvent.dtn.pxweb.*; import org.xml.sax.*; import org.w3c.dom.*; import java.io.*; // Test class class GetDailyHistoryCsv { // Main program public static void main( String[] args ) throws Exception { // Get proxy to access PXWeb PXServiceDtoXml service = new PXServiceDtoXml(); IPXServiceDtoXml client = service.getBasicHttp(); // Prepare request object GetDailyHistoryDto request = new GetDailyHistoryDto(); request.setUserID( "YOUR_USER" ); request.setPassword( "YOUR_PASSWORD" ); request.setSymbol( "@C`##,@W`##,QCL`##,QNG`##" ); request.setLimit( "10" ); // Call GetDailyHistory and get an XML element Element xml = (Element) client.getDailyHistory( request ).getAny(); // Print as CSV file printCsv( xml ); } // Print an XML document as CSV file public static void printCsv( Element xml ) throws Exception { // Aux vars String symbol = null; NodeList day = null; Node node = null; NamedNodeMap attr = null; // Print header System.out.println( "Symbol,Date,Open,Close,High,Low" ); // Get list of entries NodeList historyList = xml.getElementsByTagName( "History" ); NodeList dayList = null; // Print as CSV for( int i=0; i