xml문서 doc, element로 가져오기




     String response = mOAuthLoginInstance.requestApi( mContext, at, url );
                    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
                    DocumentBuilder db = dbf.newDocumentBuilder();
                    InputSource is = new InputSource();
                    is.setCharacterStream(new StringReader(response));
                    Document doc = db.parse(is);
                    Element resp = (Element) doc.getElementsByTagName("response").item(0);
//사용 방법은 아래와 같다.

                    uid = resp.getElementsByTagName("id").item(0).getTextContent();
                    name = resp.getElementsByTagName("name").item(0).getTextContent();
                    email = resp.getElementsByTagName("email").item(0).getTextContent();
                    created_at = "2017";

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s