Lecture 9 - XML and Java Objects Flashcards
What is the method to convert XML to java & Java to XML?
–SAX or DOM parser
•Method to convert Java to XML
–Done by printing tags
What could we use to generate XML to Java and vice - versa?
We could use:
Java beans - XML encoder
OR
By hand…
XML to Java:
- Use a parser
- Read data and create objects
Java to XML:
-Use print to generate XML
BUT… using java beans is just one way and conversion by hand is time consuming to code.
What should we use for XML to Java & vice-versa?
XML schema
–JAXB (Java Architecture for XML Binding)
•Uses schema to generate XML object code
•Schema is converted to code by special compiler
–Compiler is xjc
•Then we can use “marshalling” and “unmarshalling” to convert from XML to Java and from Java to XML
–Marshalling = Object to XML
–Unmarshing = XML to Objects