簡體   English   中英

如何從Java中的控制台從輸出文件中獲取特定的xml標記

[英]How can I get specific xml tag from output file from my console in java

這是我的代碼:我有xml文件作為輸出,我需要從該文件中獲得一個特定的標簽,嘗試{

        RestTemplate restTemplate = new RestTemplate();
        final String url = "https://wildfire.paloaltonetworks.com/publicapi/get/verdict";
        String apikey = "f719c27d2063d2e25579681a64ebc1ba";
        String hash = "a1a3b09875f9e9acade5623e1cca680009a6c9e0452489931cfa5b0041f4d290";

        HttpHeaders headers = new HttpHeaders();
        headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);

        MultiValueMap<String, String> map = new LinkedMultiValueMap<String, String>();
        map.add("apikey", apikey);
        map.add("hash", hash);

        HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<MultiValueMap<String, String>>(map, headers);


        ResponseEntity responseEntity = restTemplate.postForEntity("https://wildfire.paloaltonetworks.com/publicapi/get/verdict", request, String.class);

        System.out.println(responseEntity);

下面的鏈接將向您展示如何將XML文件(以XML文件或XML字符串開頭)轉換為文檔。

https://howtodoinjava.com/xml/parse-string-to-xml-dom/

有了文件后,您就可以...

String tag = document.getDocumentElement().getAttribute("<TAG NAME>");

希望這可以幫助

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM