Android parseXML doesn't work on API Level 28












0














    try {
hashMap = new HashMap<>();
InputStream inputStream;
URL url = new URL(params[0]);
inputStream = url.openStream();
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
Document document = documentBuilder.parse(inputStream);
Element element = document.getDocumentElement();
element.normalize();
NodeList nodeList = document.getElementsByTagName("string");
for (int current = 0; current < nodeList.getLength(); current++) {
Node node = nodeList.item(current);
if (node.getNodeType() == Node.ELEMENT_NODE) {
Element element_specific = (Element) node;
hashMap.put(element_specific.getElementsByTagName("one").item(0).getChildNodes().item(0).getNodeValue(), element_specific.getElementsByTagName("two").item(0).getChildNodes().item(0).getNodeValue());
}
}
} catch (Exception e) {
e.printStackTrace();
}


I am trying to parse an XML file using InputStream and DocumentBuilder.
It works perfectly on from API Level 23 to API Level 27, but when I execute the application on targetApi:28 and Android 9 Pie, it doesn't work and I only get the result: null.



I don't know why it happens. What's the problem?










share|improve this question






















  • Examine LogCat. Is anything getting logged from your e.printStackTrace()?
    – CommonsWare
    Nov 11 at 13:50










  • @CommonsWare Nothing Special..
    – Mium
    Nov 11 at 14:01










  • @CommonsWare is there anything different on handling url inputstream from previous APIs?
    – Mium
    Nov 11 at 14:18










  • No, though there may be issues with what your URL is. What is your URL?
    – CommonsWare
    Nov 11 at 14:36










  • @CommonsWare it works perfectly on Android 8.1. I don't think the URL is the problem.
    – Mium
    Nov 11 at 14:56
















0














    try {
hashMap = new HashMap<>();
InputStream inputStream;
URL url = new URL(params[0]);
inputStream = url.openStream();
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
Document document = documentBuilder.parse(inputStream);
Element element = document.getDocumentElement();
element.normalize();
NodeList nodeList = document.getElementsByTagName("string");
for (int current = 0; current < nodeList.getLength(); current++) {
Node node = nodeList.item(current);
if (node.getNodeType() == Node.ELEMENT_NODE) {
Element element_specific = (Element) node;
hashMap.put(element_specific.getElementsByTagName("one").item(0).getChildNodes().item(0).getNodeValue(), element_specific.getElementsByTagName("two").item(0).getChildNodes().item(0).getNodeValue());
}
}
} catch (Exception e) {
e.printStackTrace();
}


I am trying to parse an XML file using InputStream and DocumentBuilder.
It works perfectly on from API Level 23 to API Level 27, but when I execute the application on targetApi:28 and Android 9 Pie, it doesn't work and I only get the result: null.



I don't know why it happens. What's the problem?










share|improve this question






















  • Examine LogCat. Is anything getting logged from your e.printStackTrace()?
    – CommonsWare
    Nov 11 at 13:50










  • @CommonsWare Nothing Special..
    – Mium
    Nov 11 at 14:01










  • @CommonsWare is there anything different on handling url inputstream from previous APIs?
    – Mium
    Nov 11 at 14:18










  • No, though there may be issues with what your URL is. What is your URL?
    – CommonsWare
    Nov 11 at 14:36










  • @CommonsWare it works perfectly on Android 8.1. I don't think the URL is the problem.
    – Mium
    Nov 11 at 14:56














0












0








0







    try {
hashMap = new HashMap<>();
InputStream inputStream;
URL url = new URL(params[0]);
inputStream = url.openStream();
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
Document document = documentBuilder.parse(inputStream);
Element element = document.getDocumentElement();
element.normalize();
NodeList nodeList = document.getElementsByTagName("string");
for (int current = 0; current < nodeList.getLength(); current++) {
Node node = nodeList.item(current);
if (node.getNodeType() == Node.ELEMENT_NODE) {
Element element_specific = (Element) node;
hashMap.put(element_specific.getElementsByTagName("one").item(0).getChildNodes().item(0).getNodeValue(), element_specific.getElementsByTagName("two").item(0).getChildNodes().item(0).getNodeValue());
}
}
} catch (Exception e) {
e.printStackTrace();
}


I am trying to parse an XML file using InputStream and DocumentBuilder.
It works perfectly on from API Level 23 to API Level 27, but when I execute the application on targetApi:28 and Android 9 Pie, it doesn't work and I only get the result: null.



I don't know why it happens. What's the problem?










share|improve this question













    try {
hashMap = new HashMap<>();
InputStream inputStream;
URL url = new URL(params[0]);
inputStream = url.openStream();
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
Document document = documentBuilder.parse(inputStream);
Element element = document.getDocumentElement();
element.normalize();
NodeList nodeList = document.getElementsByTagName("string");
for (int current = 0; current < nodeList.getLength(); current++) {
Node node = nodeList.item(current);
if (node.getNodeType() == Node.ELEMENT_NODE) {
Element element_specific = (Element) node;
hashMap.put(element_specific.getElementsByTagName("one").item(0).getChildNodes().item(0).getNodeValue(), element_specific.getElementsByTagName("two").item(0).getChildNodes().item(0).getNodeValue());
}
}
} catch (Exception e) {
e.printStackTrace();
}


I am trying to parse an XML file using InputStream and DocumentBuilder.
It works perfectly on from API Level 23 to API Level 27, but when I execute the application on targetApi:28 and Android 9 Pie, it doesn't work and I only get the result: null.



I don't know why it happens. What's the problem?







android xml inputstream






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 11 at 13:47









Mium

338




338












  • Examine LogCat. Is anything getting logged from your e.printStackTrace()?
    – CommonsWare
    Nov 11 at 13:50










  • @CommonsWare Nothing Special..
    – Mium
    Nov 11 at 14:01










  • @CommonsWare is there anything different on handling url inputstream from previous APIs?
    – Mium
    Nov 11 at 14:18










  • No, though there may be issues with what your URL is. What is your URL?
    – CommonsWare
    Nov 11 at 14:36










  • @CommonsWare it works perfectly on Android 8.1. I don't think the URL is the problem.
    – Mium
    Nov 11 at 14:56


















  • Examine LogCat. Is anything getting logged from your e.printStackTrace()?
    – CommonsWare
    Nov 11 at 13:50










  • @CommonsWare Nothing Special..
    – Mium
    Nov 11 at 14:01










  • @CommonsWare is there anything different on handling url inputstream from previous APIs?
    – Mium
    Nov 11 at 14:18










  • No, though there may be issues with what your URL is. What is your URL?
    – CommonsWare
    Nov 11 at 14:36










  • @CommonsWare it works perfectly on Android 8.1. I don't think the URL is the problem.
    – Mium
    Nov 11 at 14:56
















Examine LogCat. Is anything getting logged from your e.printStackTrace()?
– CommonsWare
Nov 11 at 13:50




Examine LogCat. Is anything getting logged from your e.printStackTrace()?
– CommonsWare
Nov 11 at 13:50












@CommonsWare Nothing Special..
– Mium
Nov 11 at 14:01




@CommonsWare Nothing Special..
– Mium
Nov 11 at 14:01












@CommonsWare is there anything different on handling url inputstream from previous APIs?
– Mium
Nov 11 at 14:18




@CommonsWare is there anything different on handling url inputstream from previous APIs?
– Mium
Nov 11 at 14:18












No, though there may be issues with what your URL is. What is your URL?
– CommonsWare
Nov 11 at 14:36




No, though there may be issues with what your URL is. What is your URL?
– CommonsWare
Nov 11 at 14:36












@CommonsWare it works perfectly on Android 8.1. I don't think the URL is the problem.
– Mium
Nov 11 at 14:56




@CommonsWare it works perfectly on Android 8.1. I don't think the URL is the problem.
– Mium
Nov 11 at 14:56

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53249381%2fandroid-parsexml-doesnt-work-on-api-level-28%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53249381%2fandroid-parsexml-doesnt-work-on-api-level-28%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

Tangent Lines Diagram Along Smooth Curve

Yusuf al-Mu'taman ibn Hud

Zucchini