I have this code, it works, but the problem is in the example.xml file. This file accepts one value of one line.
(value>Northland College, 1411 Ellis Avenue, Ashland, Wisconsin</value>)
If we gave a few lines, it only takes one line.
<value>Northland Community and Technical College has been in existence in one form or other since 1949, when the Minnesota State Board of Education approved an area vocational school for Thief River Falls.</value>
but I want to read a few lines. Please give me an answer
example.xml
<list> <lists name="clg_history"> <tag>College_History</tag> <value>Northland Community and Technical College has been in existence in one form or other since 1949, when the Minnesota State Board of Education approved an area vocational school for Thief River Falls.</value> </lists> <lists name="clg_courses"> <tag>College_Courses</tag> <value>BTECH: CSC,IT, Civil Eng, Chemical Eng, Mechanical Eng, EEE, PG: MCA, MBA</value> </lists> <lists name="clg_address"> <tag>College_Address</tag> <value>Northland College, 1411 Ellis Avenue, Ashland, Wisconsin</value> </lists> <lists name="clg_contact"> <tag>College_Contact_Details</tag> <value>54806-3999, (715) 682-1699</value> </lists> <lists name="clg_logo"> <tag>College_Logo</tag> <value>http://www.logotypes101.com/logos/626/EC8E12391BD7F7C504C68C89A0E93484/Canisius_College.png</value> </lists> </list>
MyXMLHandler.java
public class MyXMLHandler extends DefaultHandler { Boolean currentElement = false; String currentValue=null; public static SitesList sitesList = null; public static SitesList getSitesList() { return sitesList; } public static void setSitesList(SitesList sitesList) { MyXMLHandler.sitesList = sitesList; } @Override public void startElement(String uri, String localName, String qName,Attributes attributes) throws SAXException { currentElement = true; if (localName.equals("list")) { sitesList = new SitesList(); } } @Override public void endElement(String uri, String localName, String qName) throws SAXException { currentElement = false; if (localName.equalsIgnoreCase("tag"))sitesList.setTag(currentValue); else if (localName.equalsIgnoreCase("value"))sitesList.setValue(currentValue); } @Override public void characters(char[] ch, int start, int length) throws SAXException { if (currentElement) { currentValue = new String(ch, start, length); currentElement = false; } } }
SitesList.java
public class SitesList { private static ArrayList<String> tag = new ArrayList<String>(); private static ArrayList<String> value = new ArrayList<String>(); private static String ctag; private static String cvalue; private static String clg_history_tag; private static String clg_history_value; private static String clg_address_tag; private static String clg_address_value; private static String clg_courses_tag; private static String clg_courses_value; private static String clg_contact_tag; private static String clg_contact_value; private static String clg_logo_tag; private static String clg_logo_value; public ArrayList<String> getTag() { return tag; } public void setTag(String name) { tag.add(name); } public ArrayList<String> getValue() { return value; } public void setValue(String value1) { value.add(value1); } public String getClgHistoryTag() { return clg_history_tag; } public void setClgHistoryTag(String currentValue) { clg_history_tag=currentValue; } public String getClgHistoryValue() { return clg_history_value; } public void setClgHistoryValue(String currentValue) { clg_history_value=currentValue; } public String getClgAddressTag() { return clg_address_tag; } public void setClgAddressTag(String currentValue) { clg_address_tag=currentValue; } public String getClgAddressValue() { return clg_address_value; } public void setClgAddressValue(String currentValue) { clg_address_value=currentValue; } public String getClgCoursesTag() { return clg_courses_tag; } public void setClgCoursesTag(String currentValue) { clg_courses_tag=currentValue; } public String getClgCoursesValue() { return clg_courses_value; } public void setClgCoursesValue(String currentValue) { clg_courses_value=currentValue; } public String getClgContactTag() { return clg_contact_tag; } public void setClgContactTag(String currentValue) { clg_contact_tag=currentValue; } public String getClgContactValue() { return clg_contact_value; } public void setClgContactValue(String currentValue) { clg_contact_value=currentValue; } public String getClgLogoTag() { return clg_logo_tag; } public void setClgLogoTag(String currentValue) { clg_logo_tag=currentValue; } public String getClgLogoValue() { return clg_logo_value; } public void setClgLogoValue(String currentValue) { clg_logo_value=currentValue; } }
Xmlparser.java
public class Xmlparser extends Activity { SitesList sitesList = null; @Override protected void onCreate(Bundle TravisLoveBacon) { super.onCreate(TravisLoveBacon);