url = new URL(url_str);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
connection.connect();
InputStream stream = connection.getInputStream();
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.parse(stream);
doc.getDocumentElement().normalize();
Node node = doc.getElementsByTagName("baseName").item(0);
Log.d(TAG,">>>>"+node.getNodeValue());
웹 브라우저에서 "url_str"을 시도하면 다음 XML이 표시됩니다.XML에서 GET으로부터 파싱하는 방법 (Android)
<files>
<file>
<fileId>441190</fileId>
<license>4</license>
<path>images</path>
<originalSource>
http://www.flickr.com/photos/stevendepolo/5165129565/sizes/m/
</originalSource>
<owner>Steven Depolo</owner>
<baseName>photo_5165129565_0ca9b101b0_t.jpg</baseName>
</file>
</files>
"node.getNodeValue()"를 출력하는 경우 null을 반환합니다. 하지만 baseName 태그 사이에 문자열을 가져와야합니다.