'JAVA'에 해당되는 글 51건
- 2011.10.21 java web url xml 파일 파싱
2011. 10. 21. 14:34
java web url xml 파일 파싱
2011. 10. 21. 14:34 in JAVA
public class Parse {
File file;
DocumentBuilderFactory factory;
DocumentBuilder builder;
Document doc;
StringBuffer makeHtml;
public Parse(){
}
public void init(String _urlStr){
try {
URL url = new URL(_urlStr);
InputSource is = new InputSource(url.openStream());
factory = DocumentBuilderFactory.newInstance();
builder = factory.newDocumentBuilder();
doc = builder.parse(is);
doc.getDocumentElement().normalize();
}
catch (Exception e) {
e.printStackTrace();
}
}
public void init(File _file){
try {
factory = DocumentBuilderFactory.newInstance();
builder = factory.newDocumentBuilder();
doc = builder.parse(_file);
doc.getDocumentElement().normalize();
}
catch (Exception e) {
e.printStackTrace();
}
}
}
}