I want to print out only the information I want from Java open api parsing, what should I do?

Asked 1 years ago, Updated 1 years ago, 110 views

import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL;

@SuppressWarnings("unused") public class Web_Parser_Default {

private static final String USER_AGENT = "Mozilla/5.0";
private String Address;
private URL Url;
private BufferedReader br;
private HttpURLConnection con;
private String protocol = "GET";

public Web_Parser_Default() throws Exception
{
    Address        =        "http://whois.kisa.or.kr/openapi/whois.jsp?query=kisa.or.kr&key=xxxx";

    Url = new URL(this.Address);

    con = (HttpURLConnection)Url.openConnection();
    con.setRequestMethod(protocol);
    con.setRequestProperty("User-Agent", USER_AGENT);

    br = new BufferedReader(new InputStreamReader(con.getInputStream(), "UTF-8"));

    String line;
    while((line = br.readLine()) != null)
    {
        System.out.println(line);
    }

    br.close();

}

public static void main(String[] args) throws Exception{

    Web_Parser_Default w = new Web_Parser_Default();

}

}

I parsed who is open api The result shows like this

I want to print only regName, adminEmail, and ip1 here I don't know what to do.crying Please tell me which sauce I should add

java parsing

2022-09-21 18:48

1 Answers

The result of the response is parsed into xml, and only the desired node is found and printed in the parsed xml document object.

http://www.journaldev.com/1240/java-xml-tutorial

See here.


2022-09-21 18:48

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.