Meaningless Drivel is fun!*
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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
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: 8898

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: 8898

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
 
Similar Threads
Designing a Simple Java Bean
any element and jax-ws
Using JAX-WS with JAXB problem
jaxb not unmarshalling xml any element to JAXBElement
Problem with CXF wsdl2java