Parsing wrong element....I don't know how to parse day

try {
    InputStream in = getResources().openRawResource(R.raw.database);
    DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
    Document doc = builder.parse(in);

    NodeList Day = doc.getElementsByTagName("day");
}

database.xml

<Day name = "1">
<Day name = "2">

I think I'm parsing Day's name in NodeList Day, but NodeList Day always parses "org.apache.harmony.xml.dom.NodeListImpl@41a14db8"

What I want is Day parser "1,2,3,4,5,6,7". How can I parse Day's value in NodeList day?

Jon Skeet
people
quotationmark

You're parsing the elements fine (at least as far as we can see) - it's just what you're doing with the result which is wrong. You've got a NodeList. Calling toString() on that isn't what you want - you're trying to get the name attribute of each of the nodes. So for example:

NodeList dayNodes = doc.getElementsByTagName("day");
List<String> dayNames = new List<String>();
for (int i = 0; i < dayNodes.getLength(); i++) {
    Element day = (Element) dayNodes.item(i);
    dayNames.add(day.getAttribute("name"));
}

... then do whatever you want with the list (e.g. converting it into a single comma-separated string if you really want to).

people

See more on this question at Stackoverflow