Java tutorial
//package com.java2s; /* * ? ? ? ? ? ?? ? ?? * * 2010-2016, CompuProject / . * ? . * * ShopImportDeamon ? ? ? * CompuProject ApelsinShop ? . * * ??, ? ? / * ? ?? ?, ??? ? ??: * * 1. ?? ? ??? * ? , ? ?? ? ? * . * * 2. ? ??? * ? , ? ?? ?, ? * ? ?. * * 3. ?? / ? ? * ?? ? GNU , * ? ??; * ? 3, ( ) * ?. ? * GNU ? ? ? . ? ? , ?. * <http://www.gnu.org/licenses/>. * * ShopImportDeamon ????? , , * ???; ? ?? ? * ? ?? . ?. * ? GNU. * * ? ? , ?? CompuProject ? * ? ?? ? ? , ??, ??, * , ?? ? (?, ? ? * ??? ? ?? ? ; * ??? ; ??? ??). * * ?? ??? ? ? ???, ??? * ??, ???? , ???? , ?? ? * ?. * * ? ?? ???? ??, ???? , * ?? ?? ??? ? ?. * */ import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { public static String getElementValue(Element element, String tagName, Integer n) { NodeList elementLst = element.getElementsByTagName(tagName); if (elementLst.item(n) != null) { NodeList elementData = ((Element) elementLst.item(n)).getChildNodes(); if (elementData.item(0) != null) { return ((Node) elementData.item(0)).getNodeValue(); } } return ""; } public static String getElementValue(Element element, String tagName) { return getElementValue(element, tagName, 0); } }