0

I have written a code to parse a DTD file using DTDParser jar.the code is

public static void main(String[] arg)
{
BufferedReader buff=new BufferedReader(new FileReader("abc.dtd"));
DTDParser dtd=new DTDParser(bff);
DTD dt=dtd.Parse();
System.out.println(dt.elements);
} 

and output i get is

message=com.wutka.DTDElement@c20e24...etc same as this for all elements with with diff @no changes.. But i need just the element names... also help me in putting those values in an array so i can use it for further vlidation...thank u..

sai
  • 1

1 Answers1

0

If you want elements in an array or preferably a list then you need to iterate over dt.elements such as:

List<String> elementNames = new ArrayList<String>();
for (DTDElement element : dt.elements)
{
    elementNames.add(element.getName());
}

I am not aware of the specifics of this library (i.e. getName() method might not exist) but that is a general concept.

Wojciech Owczarczyk
  • 5,595
  • 2
  • 33
  • 55
  • thank u...but another main problem is getting '=com.wutka....' in output after every element name!!! – sai Jul 11 '12 at 14:57