Answer the question
In order to leave comments, you need to log in
Collection selection when parsing XML?
I have this xml file:
<?xml version="1.0" encoding="utf-8" ?>
<list>
<file name="a" size="559393"/>
<file name="b" size="1766945"/>
</list>
Answer the question
In order to leave comments, you need to log in
I would rake in a HashMap in which the values of the name attribute would be the keys , and the values of the size attribute would be .
Map<String, String> attrs = new HashMap<>();
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
String name = attributes.getValue("name");
String value = attributes.getValue("size");
attrs.put(name, value);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question