Android 解析、修改xml文件一、DOM解析XML文件@Overridepublic void onFileItemClick(String filename){ try{ if (!filename.toLowerCase().endsWith("xml")) return; FileInputStream fis = new FileInputStream(filename); XML2Product xml2Product = new XML2Product(); android.util.Xml.parse(fis, Xml.Encoding.UTF_8, xml2Product); List<Product> products = xml2Product.getProducts(); String msg = "共" + products.size() + "个产品\n"; for (Product product : products){ msg += "id:" + product.getId() + " 产品名:" + product.getName() + " 价格:" + product.getPrice() + "\n"; } new AlertDialog.Builder(this).setTitle("产品信息").setMessage(msg).setPositiveButton("关闭", null).show(); } catch (Exception e){ }}