File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Printing element name using JAXB 2.0

 
Pradeep bhatt
Ranch Hand
Posts: 8927
Firefox Browser Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would like to extract the element name of all the types defined in my XML. Here is my code

JAXBElement object = (JAXBElement) unmarshaller.unmarshal(new FileInputStream("sample.xml"));
//this works fine
System.out.println( object.getName());

ConfigType type = (ConfigType)object.getValue();
Type1 type1 = type.getType1();

I am not able to get the elementname for type1 because it is not JAXBElement. Is there some way to convert it into JAXBElement ? I tried by passing type1 JAXBIntrospector , it printed null for element name. Please help me.
 
Pradeep bhatt
Ranch Hand
Posts: 8927
Firefox Browser Java Spring
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic