File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes XML and Related Technologies and the fly likes Printing element name using JAXB 2.0 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Printing element name using JAXB 2.0" Watch "Printing element name using JAXB 2.0" New topic
Author

Printing element name using JAXB 2.0

Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

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.


Groovy
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

http://forums.java.net/jive/thread.jspa?threadID=38171&tstart=0
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Printing element name using JAXB 2.0