tags:

views:

131

answers:

2

hi friends, How to read XML file into two dimensional array using java. Am new to this concept. Please suggest me any ideas and suggest any websites and examples regarding this question.

+1  A: 

I would recommend reading it into a map.
Use the DocumentBuilder API: http://java.sun.com/j2se/1.4.2/docs/api/javax/xml/parsers/DocumentBuilder.html

  DocumentBuilder builder = factory.newDocumentBuilder();
  document = builder.parse( new File(fileName) );

You can then use the DocumentBuilder's methods to grab the data as required e.g:

document.getElementsByTagName("NameOfTag");
David Relihan
A: 

Hi Marcelo Cantos, My xml file will be look like this

    <Map>
    <Display>0B85</Display>
    <Keys>61</Keys>
    </Map>

I want to read this xml file into two dimensional array. Suppose i have an array xml[10][40]. In this array i want to display as xml[0][0]=character and xml[0][1]=keys using java program. Please suggest any idea.

Karthi
I've giving you the starting point - get it working for one element and print to screen and the tackle the 2D array (I still think you should use a Collection - I would go with map)
David Relihan