I am having URL of PHP file from where i am getting all data in XML format.
Now i am able to read all those data using InputStream and passing to buffer.But the problem is i am not getting how can i separate all required data from the available data.I tried using DOM but it is giving me following error in my log
`Error in http connection java.net.MalformedURLException: Protocol not found in android
The code i am using is as follow.
try{
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new
HttpPost("http://www.mbusiness.com/mobile.php?id="+id.trim());
HttpResponse response;
response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
InputStream is = entity.getContent();
data = new byte[256];
buffer = new StringBuffer();
int len = 0;
while (-1 != (len = is.read(data)) )
{
buffer.append(new String(data, 0, len));
}
Log.e("log_tag",""+buffer.toString());
//Make the comparison case-insensitive.
is.close();
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(buffer.toString());
doc.getDocumentElement().normalize();
Log.e("Log.Tag",""+doc);
}
catch(Exception e){
Log.e("log_tag", "Error in http connection "+e.toString());
}
My PHP file which i am reading is giving me following details
<profile>
<details user_login="chirag"
user_nickname="chirag"
user_email="dipendra@bcod.co.in"
display_name="chirag"
first_name="chirag singh"
last_name="test singh"
nickname="chirag singh"
description=""
twitter_id=""
facebook_id=""
paypal_email=""
business_name="My Business Test"
business_abn="testabn"
business_contact="Chirag Test"
business_phone="123456789"
business_fax="123456"
business_mobile="1456789"
business_emailss="chirag@gmail.com"
business_facebookzz="http://www.facebook.com"
business_linkedin="http://www.linkedin.com"
business_myspace="http://myspacelink.com"
business_blog="Blog"
business_im="im"
business_website="tester"
business_street="TestStreet"
business_city="TestCity"
business_postcode="123456"
business_state="NSW New South Wales"
business_trading="12345"
business_area="500"
business_trade="Saturday"
business_products="TesterProducts"
business_services="testerservices"
business_delivery="only sunday"
redirect_to=""/>
</profile>
There go your DOM parser: http://xjaphx.wordpress.com/2011/10/12/android-xml-adventure-%e2%80%93-parsing-xml-data-with-dom/