Jaxb vs Jaxp (#14242)
This commit is contained in:
parent
e3058691b2
commit
0ec89aee72
|
@ -0,0 +1,9 @@
|
|||
package com.baeldung.jaxb.jaxpvsjaxb.jaxb;
|
||||
|
||||
import jakarta.xml.bind.annotation.XmlElement;
|
||||
|
||||
|
||||
public class Department {
|
||||
@XmlElement
|
||||
private String id;
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package com.baeldung.jaxb.jaxpvsjaxb.jaxb;
|
||||
|
||||
import jakarta.xml.bind.annotation.XmlElement;
|
||||
|
||||
public class Employee {
|
||||
@XmlElement
|
||||
private String id;
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package com.baeldung.jaxb.jaxpvsjaxb.jaxp;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import org.w3c.dom.Document;
|
||||
|
||||
public class JaxpExample {
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||
DocumentBuilder builder = factory.newDocumentBuilder();
|
||||
Document document = builder.parse("input.xml");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue