자바 XML 파싱문서
자바 XML 파싱문서
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
InputStream is = new ByteArrayInputStream(sbContent.toString()
.getBytes("UTF-8"));
Document doc = db.parse(is);
NodeList sub = doc.getElementsByTagName("item");
for (int i = 0; i < sub.getLength(); i++) {
System.out.println("gggggggggggg");
Node subNode = sub.item(i);
NodeList nnm = subNode.getChildNodes();
for (int j = 0; j < nnm.getLength(); j++) {
Node att = nnm.item(j);
if (subNode.getNodeType() == Node.ELEMENT_NODE) {
// System.out.print(att.getNodeName() + ": "); // 노드명을출력
// System.out.println(att.getTextContent());
if ("link".equals(att.getNodeName()))
resultUrl.add(att.getTextContent());