Advertisement
brutual123

myxml handler java class

Oct 18th, 2011
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.67 KB | None | 0 0
  1. package com.adigroup;
  2.  
  3. import java.util.ArrayList;
  4. import org.xml.sax.Attributes;
  5. import org.xml.sax.SAXException;
  6. import org.xml.sax.helpers.DefaultHandler;
  7.  
  8. import android.util.Log;
  9.  
  10. public class MyXMLHandler extends DefaultHandler {
  11.  
  12. Boolean currentElement = false;
  13. String currentValue = null;
  14.  
  15. private static String _currenTag = null;
  16.  
  17. private MallInfo _service;
  18.  
  19. public MyXMLHandler()
  20. {
  21. LogScreen1._mallInfo = new ArrayList<MallInfo>();
  22. }
  23.  
  24.  
  25. /** Called when tag starts ( ex:- <name>AndroidPeople</name>
  26. * -- <name> )*/
  27.  
  28. @Override
  29. public void startElement(String uri, String localName, String qName,
  30. Attributes attributes) throws SAXException {
  31.  
  32. _currenTag = localName;
  33.  
  34. if (localName.equals("NewDataSet"))
  35. {
  36. Log.d("Event_providers is -------------->>>>>>>>>>>>>>>>>>>>>>","" );
  37.  
  38. _service = new MallInfo();
  39.  
  40. }
  41.  
  42. if (localName.equals("EVENT_ID"))
  43. {
  44. _service = new MallInfo();
  45. }
  46.  
  47.  
  48.  
  49. }
  50.  
  51.  
  52.  
  53. /** Called when tag closing ( ex:- <name>AndroidPeople</name>
  54. * -- </name> )*/
  55. @Override
  56. public void endElement(String uri, String localName, String qName)throws SAXException {
  57.  
  58. if(localName.equalsIgnoreCase("Table"))
  59. {
  60.  
  61. LogScreen1._mallInfo.add(_service);
  62. Log.d("sizeeeeeeeeeeeeeee","sizeeeeeeeeeeeeee " +LogScreen1._mallInfo .size() );
  63. }
  64.  
  65. if(localName.equalsIgnoreCase("EVENT_ID"))
  66. {
  67.  
  68. _service.EVENT_ID = currentValue;
  69. }
  70.  
  71. if(localName.equalsIgnoreCase("EVNT_START_DATE"))
  72. {
  73. _service.EVNT_START_DATE = currentValue;
  74. }
  75.  
  76.  
  77. if(localName.equalsIgnoreCase("LOCATION"))
  78. {
  79. _service.LOCATION = currentValue;
  80. }
  81.  
  82.  
  83. }
  84.  
  85. /** Called to get tag characters ( ex:- <name>AndroidPeople</name>
  86. * -- to get AndroidPeople Character ) */
  87. @Override
  88. public void characters(char[] ch, int start, int length)throws SAXException {
  89.  
  90. Log.d("Values","***** " +_currenTag);
  91.  
  92.  
  93. if(_currenTag.equalsIgnoreCase("Table")){
  94.  
  95. currentValue = new String(ch, start, length);
  96. Log.d("event_provider is--->>","loginnnnnnnnnnnnnn" + currentValue);
  97. }
  98.  
  99.  
  100. if(_currenTag.equalsIgnoreCase("EVENT_ID"))
  101. {
  102.  
  103. currentValue = new String(ch, start, length);
  104. Log.d("Country is--->>","" + _service.Country);
  105. }
  106.  
  107.  
  108. if(_currenTag.equalsIgnoreCase("EVNT_START_DATE"))
  109. {
  110.  
  111. currentValue = new String(ch, start, length);
  112. Log.d("EVNT_START_DATE is--->>","" + _service.EVNT_START_DATE);
  113. }
  114.  
  115.  
  116. if(_currenTag.equalsIgnoreCase("LOCATION"))
  117. {
  118.  
  119. currentValue = new String(ch, start, length);
  120. Log.d("LOCATION is--->>","" + _service.LOCATION);
  121. }
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.  
  141. }
  142. }
  143.  
  144.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement