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

  • SEARCH
  • Home
  • 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 6615987
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:31:44+00:00 2026-05-25T20:31:44+00:00

I have an Xml.may i know how can i parse it. i need to

  • 0

I have an Xml.may i know how can i parse it.

i need to get all OfficeName in to an Dictionary/array from the below XML.

eg: 
Dictionary[key:tblOffice1]= "!-Everett Corporate Office" 
Dictionary[key:tblOffice2]= "!-Fullterton SCE Call Center" 
  etc..

.

the above thing is not a exact code.

please help me .

my XML is

    <DataTable xmlns="http://www.myoffice.com:1212/">
    <xs:schema xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="NewDataSet">
        <xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:MainDataTable="tblOffice" msdata:UseCurrentLocale="true">
            <xs:complexType>
                <xs:choice minOccurs="0" maxOccurs="unbounded">
            <xs:element name="tblOffice">
            <xs:complexType>
            <xs:sequence>
            <xs:element name="OfficeName" type="xs:string" minOccurs="0"/>
        </xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
<diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
<DocumentElement xmlns="">
<tblOffice diffgr:id="tblOffice1" msdata:rowOrder="0">
<OfficeName>!-Everett Corporate Office</OfficeName>
</tblOffice>
<tblOffice diffgr:id="tblOffice2" msdata:rowOrder="1">
<OfficeName>!-Fullterton SCE Call Center</OfficeName>
</tblOffice>
<tblOffice diffgr:id="tblOffice3" msdata:rowOrder="2">
<OfficeName>Columbus Office</OfficeName>
</tblOffice>
<tblOffice diffgr:id="tblOffice4" msdata:rowOrder="3">
<OfficeName>Edison Office</OfficeName>
</tblOffice>
<tblOffice diffgr:id="tblOffice5" msdata:rowOrder="4">
<OfficeName>Franklin Office</OfficeName>
</tblOffice>
<tblOffice diffgr:id="tblOffice6" msdata:rowOrder="5">
<OfficeName>Fullterton Office</OfficeName>
</tblOffice>
<tblOffice diffgr:id="tblOffice7" msdata:rowOrder="6">
<OfficeName>Hatfield Office</OfficeName>
</tblOffice>
<tblOffice diffgr:id="tblOffice8" msdata:rowOrder="7">
<OfficeName>Hayward Office</OfficeName>
</tblOffice>
<tblOffice diffgr:id="tblOffice9" msdata:rowOrder="8">
<OfficeName>Las Vegas Office</OfficeName>
</tblOffice>
<tblOffice diffgr:id="tblOffice10" msdata:rowOrder="9">
<OfficeName>Phoenix Office</OfficeName>
</tblOffice>
<tblOffice diffgr:id="tblOffice11" msdata:rowOrder="10">
<OfficeName>Portland Office</OfficeName>
</tblOffice>
<tblOffice diffgr:id="tblOffice12" msdata:rowOrder="11">
<OfficeName>Salt Lake Office</OfficeName>
</tblOffice>
<tblOffice diffgr:id="tblOffice13" msdata:rowOrder="12">
<OfficeName>Snohomish Office</OfficeName>
</tblOffice>
<tblOffice diffgr:id="tblOffice14" msdata:rowOrder="13">
<OfficeName>Spokane Office</OfficeName>
</tblOffice>
</DocumentElement>
</diffgr:diffgram>
</DataTable>

may i know , how can i do it.

i wrote the method

package com.timetracker.app;

import java.io.StringReader;

import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserFactory;

import android.app.ListActivity;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

public class OfficeLocation extends ListActivity {

    private static String SOAP_ACTION = "http://www.myoffice.com:1212/getTTofficeNames";
    private static final String METHOD_NAME  = "getTTofficeNames";
    private static  String NAMESPACE = "http://www.markdevweb.com:8082/";
    private static  String URL = "http://www.markdevweb.com:8082/ttwss/ttadmin.asmx";
    ProgressDialog pbd;
    TextView tv;
       /** Called when the activity is first created. */
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        // for getting header in the list view
        //View offheader = getLayoutInflater().inflate(R.layout.offheader,null);

        //ListView listView = getListView();
        //listView.addHeaderView(offheader);

        SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
        System.out.println("the soap object request in officeloc = " +request);
        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
        System.out.println("the soapserializationenvelope= "+envelope);
        envelope.dotNet=true;
          envelope.setOutputSoapObject(request);

       System.out.println("under the request  in officeloc");
       HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
       System.out.println("under the url  in officeloc");

       try{   
       androidHttpTransport.call(SOAP_ACTION, envelope);
       System.out.println("Under the soap action2  in officeloc");

     //SoapPrimitive resultString=(SoapPrimitive)envelope.getResponse();
      SoapObject resultString=(SoapObject)envelope.getResponse();

    System.out.println("the result string displayed  ab in officeloc :" +resultString);

     XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
      factory.setNamespaceAware(true);
      XmlPullParser xpp = factory.newPullParser();

      xpp.setInput( new StringReader (resultString.toString() ) );
      int eventType = xpp.getEventType();
      while (eventType != XmlPullParser.END_DOCUMENT) {

       if(eventType == XmlPullParser.START_DOCUMENT) {
           System.out.println("Start document");

       } else if(eventType == XmlPullParser.START_TAG) {

           System.out.println("Start tag "+xpp.getName());
       } else if(eventType == XmlPullParser.END_TAG) {
           System.out.println("End tag "+xpp.getName());
       } else if(eventType == XmlPullParser.TEXT) {
           System.out.println("Text "+xpp.getText());
       }
       eventType = xpp.next();
      }
      System.out.println("End document");
      /*  try {
            XmlPullParser parsers=new org.kxml2.io.KXmlParser();
            parsers.setInput(new java.io.StringReader("<tblOffice><OfficeName>hayword</OfficeName></tblOffice>"));
            //parsers.nextTag();
            parsers.require(XmlPullParser.START_DOCUMENT, null, null);
            parsers.nextTag();
            parsers.require(XmlPullParser.START_TAG, null, "tblOffice");
            parsers.nextTag();
            parsers.require(XmlPullParser.START_TAG, null, "OfficeName");
            System.out.println("the elements"+ parsers.getText());
            parsers.require(XmlPullParser.END_TAG, null, "OfficeName");
            parsers.nextTag();
            parsers.require(XmlPullParser.END_TAG, null, "tblOffice");
            parsers.nextTag();
            parsers.require(XmlPullParser.END_DOCUMENT, null, null);
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }*/


        String result=resultString.toString();
           System.out.println("the new value  in officeloc "+result);


          String[] names = new String[] {result};
       this.setListAdapter(new ArrayAdapter<String>(this, R.layout.officelayout,R.id.label, names));
            }

       catch (Exception e) 
       {
        tv.setText(e.getMessage());
       }



        // Create an array of Strings, that will be put to our ListActivity

        //"Everett","Hayword","SaltLake","Vegas","Snohomish","Hatfield","Bothell"
        // Use your own layout and point the adapter to the UI elements which
        // contains the label
    //with larger size  this.setListAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, names));






    }       

    @Override
    protected void onListItemClick(ListView l, View v, int position, long id) {
        super.onListItemClick(l, v, position, id);
        Object o = this.getListAdapter().getItem(position);
            String keyword = o.toString();
            Toast.makeText(OfficeLocation.this, "you have pressed" + keyword+"the position is"+position+"the ID is"+id, Toast.LENGTH_LONG)
            .show();


            if(position==0)
        {
            Context localContext1 = this.getApplicationContext();
              Intent localIntent1 = new Intent(localContext1, Everett.class);
            this.startActivity(localIntent1);
        }
                if(position==1)
                {
            Context localContext2 = this.getApplicationContext();
              Intent localIntent2 = new Intent(localContext2, Everett.class);
            this.startActivity(localIntent2);
                }
                if(position==2)
                {
            Context localContext3 = getApplicationContext();
              Intent localIntent3 = new Intent(localContext3, Everett.class);
              startActivity(localIntent3);
                }
                if(position==3)
                {
            Context localContext4 = getApplicationContext();
              Intent localIntent4 = new Intent(localContext4, Everett.class);
              startActivity(localIntent4);
                }
                if(position==4)
                {
            Context localContext5 = getApplicationContext();
              Intent localIntent5 = new Intent(localContext5, Everett.class);
              startActivity(localIntent5);
                }
                if(position==5)
                {
            Context localContext6 = getApplicationContext();
              Intent localIntent6 = new Intent(localContext6, Everett.class);
              startActivity(localIntent6);
                }
                if(position==6)
                {
            Context localContext7 = getApplicationContext();
              Intent localIntent7 = new Intent(localContext7, Everett.class);
              startActivity(localIntent7);
                }

                        }
}

However it like I am able to see get in to that method. of webservice.
and able to see the whole page I am not able to filter it out by line by line.
Its like a list of values.. but comming as the page as a whole

  • 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-05-25T20:31:45+00:00Added an answer on May 25, 2026 at 8:31 pm

    I guess what you need here is XPath, should be something like that, not tested though:

        ArrayList<String> officeNames = new ArrayList<String>();
    
        XPath xpath = XPathFactory.newInstance().newXPath();
        String expression = "//OfficeName";
        InputSource inputSource = new InputSource("offices.xml");
    
    
        NodeList nodeList;
        try {
            nodeList = (NodeList) xpath.evaluate(expression, inputSource,
                    XPathConstants.NODESET);
    
            for (int i = 0; i < nodeList.getLength(); ++i) {
                Node node = nodeList.item(i);
                officeNames.add(node.getNodeValue());
            }
        } catch (XPathExpressionException e) {
            e.printStackTrace();
        }
    

    More info about XPath in android: http://developer.android.com/reference/javax/xml/xpath/package-summary.html

    Tutorial to get the full power of XPath:
    http://www.w3schools.com/xpath/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a NSString which is passed from an xml feed........ NSString *strDate =@May
I have developed an application which can create Xml files from Xml schema with
I know you can check if all elements from one list exist in another
I have the following XML document: <projects> <project> <name>Shockwave</name> <language>Ruby</language> <owner>Brian May</owner> <state>New</state> <startDate>31/10/2008
I have XML files in a directory that I wish to get over to
I have XML with a value like the following: <products> <product id=1 name=All Products>
I have asked this question countless times on various forums. Ultimately all I need
I have a big XML file but I do not know its schema. I
I have an XML file, that may or may not contain a node called
Does anyone know how I can check if a string contains well-formed XML without

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.