// Path: src/it/sasabz/android/sasabus/SASAbus.java
// public class SASAbus extends Application {
//     private int dbDownloadAttempts;
//     
//     private static Context context = null;
//  
//     @Override
//     public void onCreate() 
//     {
//         // Init values which could be loaded from files stored in res/raw
//         setDbDownloadAttempts(0);
//         super.onCreate();
//         context = this.getApplicationContext();
//     }
// 
//     @Override
//     public void onTerminate()
//     {
//     	//do nothing
//     	MySQLiteDBAdapter.closeAll();
//     }
//     
//     /**
//      * @return the Strings and Variables stored in the Context;
//      */
//     public static Context getContext()
//     {
//     	return context;
//     }
//     
// 	/**
// 	 * @param dbDownloadAttempts the dbDownloadAttempts to set
// 	 */
// 	public void setDbDownloadAttempts(int dbDownloadAttempts) {
// 		this.dbDownloadAttempts = dbDownloadAttempts;
// 	}
// 
// 	/**
// 	 * @return the dbDownloadAttempts
// 	 */
// 	public int getDbDownloadAttempts() {
// 		return dbDownloadAttempts;
// 	}
//  
// 
// }
// 
// Path: src/it/sasabz/android/sasabus/classes/network/SASAbusXML.java
// public class SASAbusXML {
// 
// 	public Document getDomElement(String xml)
// 	{
//         Document doc = null;
//         DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
//         try {
//  
//             DocumentBuilder db = dbf.newDocumentBuilder();
//  
//             InputSource is = new InputSource();
//                 is.setCharacterStream(new StringReader(xml));
//                 doc = db.parse(is);
//  
//             } catch (ParserConfigurationException e) {
//                 Log.e("Error: ", e.getMessage());
//                 return null;
//             } catch (SAXException e) {
//                 Log.e("Error: ", e.getMessage());
//                 return null;
//             } catch (IOException e) {
//                 Log.e("Error: ", e.getMessage());
//                 return null;
//             }
//             return doc;
//     }
// 	
// 	
// 	public String getValue(Element item, String str) {
// 	    NodeList n = item.getElementsByTagName(str);
// 	    return this.getElementValue(n.item(0));
// 	}
// 	
// 	
// 	public final String getElementValue( Node elem ) {
// 	         Node child;
// 	         if( elem != null){
// 	             if (elem.hasChildNodes()){
// 	                 for( child = elem.getFirstChild(); child != null; child = child.getNextSibling() ){
// 	                     if( child.getNodeType() == Node.TEXT_NODE  ){
// 	                         return child.getNodeValue();
// 	                     }
// 	                 }
// 	             }
// 	         }
// 	         return "";
// 	  } 
// 	
// }


import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import it.sasabz.android.sasabus.R;
import it.sasabz.android.sasabus.SASAbus;
import it.sasabz.android.sasabus.classes.network.SASAbusXML;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.protocol.HTTP;
import org.apache.http.util.EntityUtils;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

/**
 *
 * XMLRequest.java
 * 
 * 
 * Copyright (C) 2012 Markus Windegger
 *
 * This file is part of SasaBus.

 * SasaBus is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * SasaBus is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with SasaBus.  If not, see <http://www.gnu.org/licenses/>.
 * 
 */
package it.sasabz.android.sasabus.classes.hafas;








public class XMLRequest {
	
	/**
	 * Requests a validation of a Station via the xml Interface of SASA
	 * @param bahnhof
	 * @return
	 */
	public static String locValRequest(String bahnhof)
	{
		String xmlrequest = "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n"+
					"<ReqC xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=" +
					"\"http://hafassrv.hacon.de/xml/hafasXMLInterface.xsd\" prod=\"manuell\" ver=\"1.1\" lang=\"DE\" "+

// Path: src/it/sasabz/android/sasabus/SASAbus.java
// public class SASAbus extends Application {
//     private int dbDownloadAttempts;
//     
//     private static Context context = null;
//  
//     @Override
//     public void onCreate() 
//     {
//         // Init values which could be loaded from files stored in res/raw
//         setDbDownloadAttempts(0);
//         super.onCreate();
//         context = this.getApplicationContext();
//     }
// 
//     @Override
//     public void onTerminate()
//     {
//     	//do nothing
//     	MySQLiteDBAdapter.closeAll();
//     }
//     
//     /**
//      * @return the Strings and Variables stored in the Context;
//      */
//     public static Context getContext()
//     {
//     	return context;
//     }
//     
// 	/**
// 	 * @param dbDownloadAttempts the dbDownloadAttempts to set
// 	 */
// 	public void setDbDownloadAttempts(int dbDownloadAttempts) {
// 		this.dbDownloadAttempts = dbDownloadAttempts;
// 	}
// 
// 	/**
// 	 * @return the dbDownloadAttempts
// 	 */
// 	public int getDbDownloadAttempts() {
// 		return dbDownloadAttempts;
// 	}
//  
// 
// }
// 
// Path: src/it/sasabz/android/sasabus/classes/network/SASAbusXML.java
// public class SASAbusXML {
// 
// 	public Document getDomElement(String xml)
// 	{
//         Document doc = null;
//         DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
//         try {
//  
//             DocumentBuilder db = dbf.newDocumentBuilder();
//  
//             InputSource is = new InputSource();
//                 is.setCharacterStream(new StringReader(xml));
//                 doc = db.parse(is);
//  
//             } catch (ParserConfigurationException e) {
//                 Log.e("Error: ", e.getMessage());
//                 return null;
//             } catch (SAXException e) {
//                 Log.e("Error: ", e.getMessage());
//                 return null;
//             } catch (IOException e) {
//                 Log.e("Error: ", e.getMessage());
//                 return null;
//             }
//             return doc;
//     }
// 	
// 	
// 	public String getValue(Element item, String str) {
// 	    NodeList n = item.getElementsByTagName(str);
// 	    return this.getElementValue(n.item(0));
// 	}
// 	
// 	
// 	public final String getElementValue( Node elem ) {
// 	         Node child;
// 	         if( elem != null){
// 	             if (elem.hasChildNodes()){
// 	                 for( child = elem.getFirstChild(); child != null; child = child.getNextSibling() ){
// 	                     if( child.getNodeType() == Node.TEXT_NODE  ){
// 	                         return child.getNodeValue();
// 	                     }
// 	                 }
// 	             }
// 	         }
// 	         return "";
// 	  } 
// 	
// }


// Path: src/it/sasabz/android/sasabus/classes/hafas/XMLRequest.java
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import it.sasabz.android.sasabus.R;
import it.sasabz.android.sasabus.SASAbus;
import it.sasabz.android.sasabus.classes.network.SASAbusXML;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.protocol.HTTP;
import org.apache.http.util.EntityUtils;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

/**
 *
 * XMLRequest.java
 * 
 * 
 * Copyright (C) 2012 Markus Windegger
 *
 * This file is part of SasaBus.

 * SasaBus is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * SasaBus is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with SasaBus.  If not, see <http://www.gnu.org/licenses/>.
 * 
 */
package it.sasabz.android.sasabus.classes.hafas;








public class XMLRequest {
	
	/**
	 * Requests a validation of a Station via the xml Interface of SASA
	 * @param bahnhof
	 * @return
	 */
	public static String locValRequest(String bahnhof)
	{
		String xmlrequest = "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n"+
					"<ReqC xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=" +
					"\"http://hafassrv.hacon.de/xml/hafasXMLInterface.xsd\" prod=\"manuell\" ver=\"1.1\" lang=\"DE\" "+

					"accessId=\"" + SASAbus.getContext().getResources().getString(R.string.accessId) + "\">\n<LocValReq id=\"toInput\" >\n" +
