안드로이드 개발 질문/답변
(글 수 45,052)
void myParser(String url) { try {// DocumentBuilderFactory를 이용해서 DocumentBuilder 클래스 객체화
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
// 파싱 하기 위한 문자열을 ByteArrayInputStream으로 변환
InputStream iStream = new ByteArrayInputStream(url.getBytes("UTF-8"));// DocumentBuilder클래스를 이용하여 파싱 -> 결과값을 Document 객체로 반환
Document doc = builder.parse(iStream);
// 파싱된 XML 문서의 루트 엘리먼트 획득
Element order = doc.getDocumentElement();
// 태그명을 이용하여 노드리스트 획득
NodeList items = order.getElementsByTagName("CAR_NUM");// 노드리스트 0번 획득(첫번째)
for (int i = 0; i < items.getLength(); i++) {Node item = items.item(i);
Node text = item.getFirstChild();
String val = (String)text.getNodeValue();
if (val.equalsIgnoreCase(input.toString())) { status.setText("맞다 에헤헤"+val.hashCode()+"와"+input.toString().hashCode()); }else{ status.setText("틀리다 에헤헤"+val.hashCode()+"와"+input.toString().hashCode());}
Log.e("sig", text.getNodeValue());}//i end
} catch (Exception e) {}//catch end
}
DOM 파서를 사용해서 데이터를 가져 온 다음 그걸 EditText에 입력된 값과 비교하는 코드 인데요
도무지 비교가 되지 않아서 애를 먹고 있습니다. 정녕 비교 할 방법은 없는건가요? ㅠ_ㅠ



