XML 파일 파싱할 때 파일이 아니고 객체(스트링 등)에서 받아오는 방법

조회 1,986 · 댓글 1
영웅문작성자2017년 1월 18일
XPATH를 사용해서 XML 파싱을 하고 있는데요.


DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(xmlFile);


혹시 파일로부터 읽는게 아니고 String 객체에서 읽어오는 방법이 있을까요?
강철지그강철지그2017년 1월 20일
InputSource is = new InputSource(new StringReader(xmlFileContent));

Document doc = builder.parse(is);


혹은


ByteArrayInputStream is = new ByteArrayInputStream(xmlFileContent.getBytes());

Document doc = builder.parse(is);

로그인 후 답글을 남길 수 있습니다.