0

Suppose i have an XML file name movies.xml and i know what are the tags in it then it is very easy for me to parse using jsoup in java.But now assume I don't know what are the tags and what is the no. of tags but I want to get all data then how will I get it? How will i parse XML generically ? What algorithm i should use ?

Ajay Yadav
  • 9
  • 1
  • 2

2 Answers2

1

With a parser like DOM Parser/Builder (out of the box support); you will find a method called getChildNodes() which will retrieve all the children from the root node. You can then process each of these appropriately.

You can also have a look at: Which is the best library for XML parsing in java as well as Iterate all XML node generations in java DOM for some more insight.

Community
  • 1
  • 1
Jaco Van Niekerk
  • 4,013
  • 2
  • 19
  • 43
0

Just invoke an XML parser and the parser will tell you what elements it finds.

Michael Kay
  • 147,186
  • 10
  • 83
  • 148