I
I
Ilya2013-12-29 09:21:35
Java
Ilya, 2013-12-29 09:21:35

XML file not opening?

Everything is very simple, and I do not understand why!

Document dom = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(file);

after calling this construct, the value dom = [#document: null]. That is, the value is assigned, but the file seems to be empty...
And the XML file itself:
<?xml version="1.0" encoding="UTF-8" ?>
<jtablemodel>
  <column name="Альтернативы" >
    <item>Петя</item>
    <item>Вася</item>
    <item> ... </item>
    <item>Игорь</item>
  </column>
</jtablemodel>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Ruslan Lopatin, 2013-12-29
@rpsv

Obviously, you made a mistake with the file parameter. Check that this file exists (file.exists()). Print its content before passing it to parse.

J
jamesmalvi, 2015-04-03
@jamesmalvi

One of the best tools for XML is codebeautify.org/xmlviewer XML formatter, XML validator, XML minify, XML to JSON, XML to CSV

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question