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 8559031
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T15:56:43+00:00 2026-06-11T15:56:43+00:00

I have create a webservice looks like : <?xml version=1.0 encoding=UTF-8 standalone=yes ?> –

  • 0

I have create a webservice looks like :

 <?xml version="1.0" encoding="UTF-8" standalone="yes" ?> 
- <todoLists>
- <todoList>
  <productId>smthig</productId> 
  <siteCode>smthing</siteCode> 
  <subDeptId>smthing</subDeptId> 
  </todoList>
  </todoLists>

and i am trying to parse it using DOM parser using below code , i am getting nodeList.getLength() = 20 but not getting the value of the elements .it is showing null i have also tried the SAX parser but that is also giving null. Is there anything wrong with the webservice ?? please suggest.

public class XMLParsingDOMExample extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        /** Create a new layout to display the view */
        LinearLayout layout = new LinearLayout(this);
        layout.setOrientation(1);

        /** Create a new textview array to display the results */


        TextView category[];

        try {

            URL url = new URL(
            "http://xxxxxx:8080/webservicedemo/rest/todo");
            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
            DocumentBuilder db = dbf.newDocumentBuilder();
            Document doc = db.parse(new InputSource(url.openStream()));
            doc.getDocumentElement().normalize();

            NodeList nodeList = doc.getElementsByTagName("todoList");
            System.out.println("null 1");
            /** Assign textview array lenght by arraylist size */


            category = new TextView[nodeList.getLength()];
            System.out.println("null 122 nodeList.getLength()" +nodeList.getLength());
            for (int i = 0; i < nodeList.getLength(); i++) {

                Node node = nodeList.item(i);
                category[i] = new TextView(this);
                Element fstElmnt = (Element) node;
                category[i].setText("Name = "
                        + fstElmnt.getAttribute("siteCode"));


                layout.addView(category[i]);
                System.out.println("null 551");

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

        /** Set the layout view to display */
        setContentView(layout);

    }


    public class RSSAdapter extends BaseAdapter {
        Element rootElement;

        public RSSAdapter(Element rootElement) {
            this.rootElement = rootElement;
        }

        public int getCount() {
            // get the count of children of the root element
            return 0;
        }

        public Object getItem(int position) {
            // get the child identified by the position, 
            // this is the important part where you    
            // want to get the right child representing the RSS data that you want to get
            return null;
        }

        public long getItemId(int position) {
            return position;
        }

        public View getView(int position, View convertView, ViewGroup parent) {
            // implement your view here....
            return null;
        }
    }

}
  • 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-11T15:56:44+00:00Added an answer on June 11, 2026 at 3:56 pm

    in your case siteCode is not Attributes its Node of todoList

    Solution

        NodeList nlList = eElement.getElementsByTagName("siteCode").item(0).getChildNodes();
        Node nValue = (Node) nlList.item(0);
        category[i].setText(nValue.getNodeValue());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have XML-request from web service. It looks like this. So, how can I
I have a C# webservice in .net 4.0. The webservice will create a file
I have a restfull webservice that requires loading trained model files and to create
I have a winforms, and it connecting wit webservice. Webservice has method which create
I am using latest Apache CXF to create a webservice. I have configured ws-security
i have a web service working like this: @WebService(serviceName = TempService) public class TempService
I am trying to create an org.w3c.dom.Document object from an xml string. I have
I have created a helper to parse time froma webservice and output inanother format
We have tried to create sample webservices helloworld in Java using Jersey and Tomcat
I have created one application in flex that is accessing the Java webservice using

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.