1 7 package com.bull.eclipse.jonas.utils.xml; 8 9 import java.io.File ; 10 import java.io.FileInputStream ; 11 import java.io.FileNotFoundException ; 12 import java.io.IOException ; 13 14 import javax.xml.parsers.ParserConfigurationException ; 15 16 import org.w3c.dom.Document ; 17 import org.w3c.dom.NodeList ; 18 import org.xml.sax.SAXException ; 19 20 import com.bull.eclipse.jonas.JonasLauncherPlugin; 21 22 28 public class GetNodeInXmlFile { 29 30 public static String getValueForNode(File xmlFile, String node) { 31 try { 32 FileInputStream is = new FileInputStream (xmlFile); 33 Document docXmlWeb = XMLUtils.newDocument(is,true); 34 35 NodeList nlSC = docXmlWeb.getElementsByTagName(node); 36 for(int i = 0;i < nlSC.getLength(); i++) { 37 JonasLauncherPlugin.log("Node Value = " + nlSC.item(i).getFirstChild().getNodeValue()); 38 return nlSC.item(i).getFirstChild().getNodeValue(); 39 } 40 41 } catch (FileNotFoundException e) { 42 e.printStackTrace(); 44 } catch (ParserConfigurationException e) { 45 e.printStackTrace(); 47 } catch (SAXException e) { 48 e.printStackTrace(); 50 } catch (IOException e) { 51 e.printStackTrace(); 53 } 54 return null; 55 } 56 57 58 } 59 | Popular Tags |