Android parseXML doesn't work on API Level 28
up vote
0
down vote
favorite
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
|
show 2 more comments
up vote
0
down vote
favorite
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
Examine LogCat. Is anything getting logged from youre.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
|
show 2 more comments
up vote
0
down vote
favorite
up vote
0
down vote
favorite
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
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
android xml inputstream
asked Nov 11 at 13:47
Mium
338
338
Examine LogCat. Is anything getting logged from youre.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
|
show 2 more comments
Examine LogCat. Is anything getting logged from youre.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
|
show 2 more comments
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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