Win a copy of Fixing your Scrum this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Rob Spoor
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Holloway
  • Piet Souris
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Frits Walraven
  • Himai Minh

processing xml file in java

Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi! All
I have to process/handle a xml file in my java for this i'm using JAXB API.This is what i have understood uptill now regarding JAXB. JAXB producing the Java files from the XML schema and then unmarshalling xml data into java object.In the unmarshalling process you begin with a valid XML file and convert it to Java objects that are instances of the classes that were created by the JAXB schema on the whole You will perform two basic activities when working with a data binding solution. You will compile the schema into Java source files that contain interfaces and classes. You will then use these generated classes along with the APIs provided for handling generated files.
Java files are then created by giving the following command

java -jar [JAXB_LIB]\ abc.xsd .Suppose it generates the corrosponding java files in the folder structure

Now to unmarshal XML content into a content tree of data objects, you first create a JAXBContext instance for handling schema-derived classes, then create an Unmarshaller instance, and then finally unmarshal the XML content. For example, if the generated classes are in a package named MyPackage and the XML content is in a file named abc.xml:

JAXBContext jc = JAXBContext.newInstance( "MyPackage" );
Unmarshaller u = jc.createUnmarshaller();
PurchaseOrder po =
(PurchaseOrder)u.unmarshal( new FileInputStream( "abc.xml" ) );

Now i want to know whether i have to invoke the command
java -jar [JAXB_LIB]\abc.xsd
dynamically using the java.lang.Runtime execute(String command)
to get the generated java classes in some folder,as we work on the generated java classes to unmarshal it.

Any help will be greatly appreciated.
Many Regards
Ved Gunjan.
I didn't like the taste of tongue and it didn't like the taste of me. I will now try this tiny ad:
the value of filler advertising in 2021
    Bookmark Topic Watch Topic
  • New Topic