XML 응용과 기술 9장 연습문제
- 최초 등록일
- 2010.09.14
- 최종 저작일
- 2010.05
- 12페이지/ MS 워드
- 가격 1,000원
소개글
XML 응용과 기술 책 9장 연습문제입니다. 실행 결과 캡쳐도 했습니다
목차
1. DOM API를 기반으로 아래에 XML 문서를 읽어 들여서 students_test.xml파일로 출력하는 프로그램을 작성하시오.
2. 위의 1번 문제의 students.xml 파일의 내용에 < student > 요소의 자식요소로 < address > 요소를 추가하고 요소내용으로‘서울’을 추가하는, 다음과 같은 XML 문서를 출력하는 프로그램을 작성하시오.
4. 다음 XML 문서에서 < address >요소 데이터가 “서”로 시작하는 데이터를 추출하고 address.xml파일로 출력하는 프로그램을 작성하시오.
본문내용
import java.io.*;
import javax.xml.parsers.*;
import org.w3c.dom.*;
import org.apache.crimson.tree.*;
class DOMIO
{
public static void main(String args[]) throws Exception
{
if (args.length != 2)
{
System.out.println("usage : >java DOMIO <input-file name> <output-file name>");
System.exit(1);
}
String infilename= args[0];
String outfilename= args[1];
DocumentBuilderFactory DocBF
= DocumentBuilderFactory.newInstance();
DocumentBuilder DocB
= DocBF.newDocumentBuilder();
Document Doc
= DocB.parse(new FileInputStream(infilename));
XmlDocument XDoc = (XmlDocument) Doc;
BufferedWriter BufW
= new BufferedWriter(new FileWriter(outfilename));
XDoc.write(BufW,"EUC-KR");
}
}
참고 자료
XML 응용과 기술