我在java中读取一个文件我希望数据如firstname,lastname,nickname,来自该文件中每个嵌套学生标记的标记如何在java文件中读取和写入以下概念是我的文件
<class>
<student rollno="393">
<firstname>dinkar</firstname>
<lastname>kad</lastname>
<nickname>dinkar</nickname>
<marks>85</marks>
</student>
<student rollno="493">
<firstname>Vaneet</firstname>
<lastname>Gupta</lastname>
<nickname>vinni</nickname>
<marks>95</marks>
</student>
<student rollno="593">
<firstname>jasvir</firstname>
<lastname>singn</lastname>
<nickname>jazz</nickname>
<marks>90</marks>
<student rollno="594">
<firstname>jasvir</firstname>
<lastname>singn</lastname>
<nickname>jazz</nickname>
<marks>90</marks>
</student>
</student>
</class>
答案 0 :(得分:-1)
希望这对你有所帮助,我最初写这篇文章是为了将xml元素提取为java对象 https://github.com/izi-SL/CSV-XML-Parser/tree/master/ParserProject/src/com/isuru/xmlreader
如果这不适合您的要求,请尝试DOM或SAX解析器