Failing to get element values using Element.getAttribute()

后端 未结 4 539
北恋
北恋 2021-01-14 05:14

I would like to read an xml file. I\' ve found an example which is good until the xml element doesn\'t have any attributes. Of course i\'ve tried to look after how could I r

4条回答
  •  粉色の甜心
    2021-01-14 05:47

    If you're looking purely to obtain attributes (E.g. a config / ini file) I would recommend using a java properties file.

    http://docs.oracle.com/javase/tutorial/essential/environment/properties.html

    If you just want to read a file create a new fileReader and put it into a bufferedReader.

    BufferedReader in = new BufferedReader(new FileReader("example.xml"));
    

提交回复
热议问题