У меня это работало, я где-то внес изменения, и теперь я не могу отследить ошибку.
Вот ситуация ... когда создается _regionList, в xml-файле есть 13 областей для региона, который я использую, но массив _regionlist / children / имеет 18 объектов. Используя другой регион (50 элементов), он создает 60 объектов.
Остальные объекты в массиве, конечно, имеют нулевой идентификатор, что является проблемой. Есть мысли о том, как туда попадают дополнительные объекты?
Спасибо
// Разбор XML-файла
public void Parse(InputStream inStream, String inRegion)
{
try {
String _region = inRegion;
this.cFactory = DocumentBuilderFactory.newInstance();
this.cBuilder = this.cFactory.newDocumentBuilder();
this.cBuilder.isValidating();
Document _document = this.cBuilder.parse(inStream, null);
_document.getDocumentElement().normalize();
NodeList _regionList = _document.getElementsByTagName(_region);
final int _length = _regionList.getLength();
for (int i = 0; i < _length; i++) {
final NamedNodeMap _attr = _regionList.item(i).getAttributes();
final String _regionName = GetNodeValue(_attr, "name");
// Construct a Region object
PropertiesRegion _regionObject = new PropertiesRegion(_regionName);
// Add to list
this.cList.add(_regionObject);
Log.d(TAG, _regionObject.toString());
}
}
catch (SAXException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
catch (ParserConfigurationException e)
{
e.printStackTrace();
}
}