Wednesday, January 26, 2011

Get Tag value fro XML Document(org.w3c.dom.Document) -Blackberry Java development


    /**
     * @param document
     * @param node
     * @param index
     * @return element value
     * getTag(Document document, String node,int index)
     */
    public static String getTag(Document document, String node,int index) 
    {
    NodeList nodeList = document.getElementsByTagName(node);
    String returnString = "";
    if (nodeList != null && nodeList.getLength() > 0) {
        nodeList = nodeList.item(index).getChildNodes();
        if (nodeList != null && nodeList.getLength() > 0) {
        returnString = nodeList.item(0).getNodeValue();
        }
    }
    return returnString;
    }

1 comment: