public class Connection {
private URL _url;
private InputStream is;
private XmlPullParser _parser;
public Connection(String _urlString) {
// TODO Auto-generated constructor stub
try{
_url= new URL(_urlString);
is=_url.openConnection().getInputStream();
_parser=Xml.newPullParser();
_parser.setInput(is, null);
}
catch(Exception ex){
}
}
public String getLoginData() {
String _success = null;
try {
int eventType = _parser.getEventType();
boolean done = false;
while (eventType != XmlPullParser.END_DOCUMENT && !done){
String name = null;
switch (eventType){
case XmlPullParser.START_DOCUMENT:
break;
case XmlPullParser.START_TAG:
name = _parser.getName();
Log.d("Start tagggggggggggggg","start tagggggggggggg " + name);
if (name.equalsIgnoreCase("Art")){
_success= _parser.getAttributeValue(null,"Success");
Log.d("stateeeeeeeeeee","stateeeeeeeeeee" + _success);
}
break;
case XmlPullParser.END_TAG:
name = _parser.getName();
if (name.equalsIgnoreCase("Art")){
//messages.add(_loginData);
}
break;
}
eventType = _parser.next();
}
} catch (Exception e) {
Log.e("AndroidNews::PullFeedParser", e.getMessage(), e);
throw new RuntimeException(e);
}
return _success;
}
public ArrayList<StatesData> getStateData() {
ArrayList<StatesData> messages = null;
try {
int eventType = _parser.getEventType();
StatesData _loginData = null;
boolean done = false;
while (eventType != XmlPullParser.END_DOCUMENT && !done){
String name = null;
switch (eventType){
case XmlPullParser.START_DOCUMENT:
messages = new ArrayList<StatesData>();
break;
case XmlPullParser.START_TAG:
name = _parser.getName();
Log.d("Start tagggggggggggggg","start tagggggggggggg " + name);
if (name.equalsIgnoreCase("Art")){
_loginData = new StatesData();
_loginData.id = _parser.getAttributeValue(null,"Success");
Log.d("stateeeeeeeeeee","stateeeeeeeeeee" + _loginData.id);
_loginData._stateName = _parser.getAttributeValue(null,"DuplicateEmail");
Log.d("stateeeeeeeeeee","stateeeeeeeeeee" + _loginData._stateName);
}
break;
case XmlPullParser.END_TAG:
name = _parser.getName();
if (name.equalsIgnoreCase("Art") && _loginData != null){
messages.add(_loginData);
}
break;
}
eventType = _parser.next();
}
} catch (Exception e) {
Log.e("AndroidNews::PullFeedParser", e.getMessage(), e);
throw new RuntimeException(e);
}
return messages;
}
}
public ArrayList<MessageData> getmessagedata() {
ArrayList<MessageData> messagesAL = null;
try {
int eventType = _parser.getEventType();
MessageData _messageData = null;
boolean done = false;
while (eventType != XmlPullParser.END_DOCUMENT && !done){
String name = null;
switch (eventType){
case XmlPullParser.START_DOCUMENT:
messagesAL = new ArrayList<MessageData>();
break;
case XmlPullParser.START_TAG:
name = _parser.getName();
Log.d("Start tagggggggggggggg","start tagggggggggggg " + name);
if (name.equalsIgnoreCase("Detail")){
_messageData = new MessageData();
_messageData._msgid = _parser.getAttributeValue(null,"MessageId");
Log.d("iddddddddd","iddddddddddddddddddd" + _messageData._msgid);
_messageData._sendername= _parser.getAttributeValue(null,"SenderName");
Log.d("descriptionnnnnnnnnnnnn","descriptionnnnnnnnnnn" +_messageData._sendername);
_messageData._image = _parser.getAttributeValue(null,"SenderImage");
Log.d("imageeeeeeeee","imageeeeeeeeeeeeeeeeee" + _messageData._image);
_messageData._messdesc= _parser.getAttributeValue(null,"Message");
Log.d("descriptionnnnnnnnnnnnn","descriptionnnnnnnnnnn" + _messageData._messdesc);
_messageData._time= _parser.getAttributeValue(null,"MessageTime");
Log.d("descriptionnnnnnnnnnnnn","descriptionnnnnnnnnnn" + _messageData._time);
}
break;
case XmlPullParser.END_TAG:
name = _parser.getName();
if (name.equalsIgnoreCase("Detail") && _messageData != null){
messagesAL.add(_messageData);
}
break;
}
eventType = _parser.next();
}
} catch (Exception e) {
Log.e("AndroidNews::PullFeedParser", e.getMessage(), e);
throw new RuntimeException(e);
}
return messagesAL;
}
By: Parmil.S & VkHooda
private URL _url;
private InputStream is;
private XmlPullParser _parser;
public Connection(String _urlString) {
// TODO Auto-generated constructor stub
try{
_url= new URL(_urlString);
is=_url.openConnection().getInputStream();
_parser=Xml.newPullParser();
_parser.setInput(is, null);
}
catch(Exception ex){
}
}
public String getLoginData() {
String _success = null;
try {
int eventType = _parser.getEventType();
boolean done = false;
while (eventType != XmlPullParser.END_DOCUMENT && !done){
String name = null;
switch (eventType){
case XmlPullParser.START_DOCUMENT:
break;
case XmlPullParser.START_TAG:
name = _parser.getName();
Log.d("Start tagggggggggggggg","start tagggggggggggg " + name);
if (name.equalsIgnoreCase("Art")){
_success= _parser.getAttributeValue(null,"Success");
Log.d("stateeeeeeeeeee","stateeeeeeeeeee" + _success);
}
break;
case XmlPullParser.END_TAG:
name = _parser.getName();
if (name.equalsIgnoreCase("Art")){
//messages.add(_loginData);
}
break;
}
eventType = _parser.next();
}
} catch (Exception e) {
Log.e("AndroidNews::PullFeedParser", e.getMessage(), e);
throw new RuntimeException(e);
}
return _success;
}
public ArrayList<StatesData> getStateData() {
ArrayList<StatesData> messages = null;
try {
int eventType = _parser.getEventType();
StatesData _loginData = null;
boolean done = false;
while (eventType != XmlPullParser.END_DOCUMENT && !done){
String name = null;
switch (eventType){
case XmlPullParser.START_DOCUMENT:
messages = new ArrayList<StatesData>();
break;
case XmlPullParser.START_TAG:
name = _parser.getName();
Log.d("Start tagggggggggggggg","start tagggggggggggg " + name);
if (name.equalsIgnoreCase("Art")){
_loginData = new StatesData();
_loginData.id = _parser.getAttributeValue(null,"Success");
Log.d("stateeeeeeeeeee","stateeeeeeeeeee" + _loginData.id);
_loginData._stateName = _parser.getAttributeValue(null,"DuplicateEmail");
Log.d("stateeeeeeeeeee","stateeeeeeeeeee" + _loginData._stateName);
}
break;
case XmlPullParser.END_TAG:
name = _parser.getName();
if (name.equalsIgnoreCase("Art") && _loginData != null){
messages.add(_loginData);
}
break;
}
eventType = _parser.next();
}
} catch (Exception e) {
Log.e("AndroidNews::PullFeedParser", e.getMessage(), e);
throw new RuntimeException(e);
}
return messages;
}
}
public ArrayList<MessageData> getmessagedata() {
ArrayList<MessageData> messagesAL = null;
try {
int eventType = _parser.getEventType();
MessageData _messageData = null;
boolean done = false;
while (eventType != XmlPullParser.END_DOCUMENT && !done){
String name = null;
switch (eventType){
case XmlPullParser.START_DOCUMENT:
messagesAL = new ArrayList<MessageData>();
break;
case XmlPullParser.START_TAG:
name = _parser.getName();
Log.d("Start tagggggggggggggg","start tagggggggggggg " + name);
if (name.equalsIgnoreCase("Detail")){
_messageData = new MessageData();
_messageData._msgid = _parser.getAttributeValue(null,"MessageId");
Log.d("iddddddddd","iddddddddddddddddddd" + _messageData._msgid);
_messageData._sendername= _parser.getAttributeValue(null,"SenderName");
Log.d("descriptionnnnnnnnnnnnn","descriptionnnnnnnnnnn" +_messageData._sendername);
_messageData._image = _parser.getAttributeValue(null,"SenderImage");
Log.d("imageeeeeeeee","imageeeeeeeeeeeeeeeeee" + _messageData._image);
_messageData._messdesc= _parser.getAttributeValue(null,"Message");
Log.d("descriptionnnnnnnnnnnnn","descriptionnnnnnnnnnn" + _messageData._messdesc);
_messageData._time= _parser.getAttributeValue(null,"MessageTime");
Log.d("descriptionnnnnnnnnnnnn","descriptionnnnnnnnnnn" + _messageData._time);
}
break;
case XmlPullParser.END_TAG:
name = _parser.getName();
if (name.equalsIgnoreCase("Detail") && _messageData != null){
messagesAL.add(_messageData);
}
break;
}
eventType = _parser.next();
}
} catch (Exception e) {
Log.e("AndroidNews::PullFeedParser", e.getMessage(), e);
throw new RuntimeException(e);
}
return messagesAL;
}
By: Parmil.S & VkHooda
No comments:
Post a Comment