Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8417545
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T02:04:48+00:00 2026-06-10T02:04:48+00:00

I have this code, this is working, but problem is in this example.xml file,In

  • 0

I have this code,
this is working, but problem is in this example.xml file,In this file single value single line is accepted.

(value>Northland College, 1411 Ellis Avenue, Ashland, Wisconsin</value>)

If we gave multiple line it will take only a single line read.

<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 a multiple line read.Please give me a 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"))
        {
            /** Start */ 
            sitesList = new SitesList(); 
        }
    }    

    /** Called when tag closing ( ex:- <name>AndroidPeople</name> 
     * -- </name> )*/
    @Override
    public void endElement(String uri, String localName, String qName) throws SAXException {

        currentElement = false;

        /** set value */ 
        if (localName.equalsIgnoreCase("tag"))sitesList.setTag(currentValue);
        else if (localName.equalsIgnoreCase("value"))sitesList.setValue(currentValue);


    }

    /** Called to get tag characters ( ex:- <name>AndroidPeople</name> 
     * -- to get AndroidPeople Character ) */
    @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 {

/** Variables */
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;

/** In Setter method default it will return arraylist 
 *  change that to add  */


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);
    // making it full screen
    requestWindowFeature(Window.FEATURE_NO_TITLE);
            getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.splash);

    TextView tag[];
    TextView value[];


    try {

    /** Handling XML */
    SAXParserFactory spf = SAXParserFactory.newInstance();
    SAXParser sp = spf.newSAXParser();
    XMLReader xr = sp.getXMLReader();

    /** Send URL to parse XML Tags */
     InputSource is = new InputSource(getResources().openRawResource(R.raw.example));

    /** Create handler to handle XML Tags ( extends DefaultHandler ) */
    MyXMLHandler myXMLHandler = new MyXMLHandler();
    xr.setContentHandler(myXMLHandler);
    xr.parse(new InputSource(is.getByteStream()));

    } catch (Exception e) {
    System.out.println("XML Pasing Excpetion = " + e);
    }

    /** Get result from MyXMLHandler SitlesList Object */
    sitesList = MyXMLHandler.sitesList;


    //System.out.println("");
    /** Assign textview array lenght by arraylist size */
    tag = new TextView[sitesList.getTag().size()];
    System.out.println("tags"+sitesList.getTag().size());
    value = new TextView[sitesList.getValue().size()];
    System.out.println("values"+sitesList.getValue().size());


    /** Set the result text in textview and add it to layout */

    sitesList.setClgHistoryTag(sitesList.getTag().get(0));
    sitesList.setClgHistoryValue(sitesList.getValue().get(0));

    sitesList.setClgCoursesTag(sitesList.getTag().get(1));
    sitesList.setClgCoursesValue(sitesList.getValue().get(1));

    sitesList.setClgAddressTag(sitesList.getTag().get(2));
    sitesList.setClgAddressValue(sitesList.getValue().get(2));

    sitesList.setClgContactTag(sitesList.getTag().get(3));
    sitesList.setClgContactValue(sitesList.getValue().get(3));

    sitesList.setClgLogoTag(sitesList.getTag().get(4));
    sitesList.setClgLogoValue(sitesList.getValue().get(4));


    System.out.println(sitesList.getClgHistoryValue());
    System.out.println(sitesList.getClgCoursesValue());
    System.out.println(sitesList.getClgAddressValue());
    System.out.println(sitesList.getClgContactValue());
    System.out.println(sitesList.getClgLogoValue());

}
    @Override
    protected void onPause() {
        super.onPause();
        finish();

    }


}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T02:04:50+00:00Added an answer on June 10, 2026 at 2:04 am

    I haven’t tested this but I suspect the linefeed in the characters is giving problems. Try change your character() method in the xml handler to:

    currentValue = new String(ch, start, length).replaceAll("\\r\\n|\\r|\\n", " ");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have this code and its working but i want it to return dailyTotals
this seems to be weird but it really happened. I have this code working
I have this working code, but now i need to be able to change
i have tried this code to redirect a php page.but it s not working
I have this code working in C#: var request = (HttpWebRequest)WebRequest.Create(https://x.com/service); request.Method = GET;
I used to have this code working with my Tomcat server: HttpRequestBase targetRequest =
I have this JQuery code working however I need to know whether how to
i have this code $(function() { $('#ans_vote a span').click(function(){alert('working');return false;});}); and this html <div
Hi Javascript gurus, I have this Javascript code which is working fine on Firefox
As a beginner in Ocaml, I have this current working code: ... let ch_in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.