jaxb を使用して xml を Java に変換するためのコードを提案できますか。私のxmlファイルは次のようになります
<Customer>
<Operation>Sample</Operation>
<head>
<sub>
<value>
<att>
<req>
<name>sample</name>
<value>
<string> sample values </string>
</value>
</req>
</att>
</value>
</sub>
<sub>
<value>
<att>
<req>
<name>var</name>
<value>
<string>var value</string>
</value>
</req>
</att>
</value>
</sub>
</head>
</Customer>
次のコードを使用しましたが、null 値を取得しています
File file = new File("C:\\xml.xml");
JAXBContext jaxbContext = JAXBContext.newInstance(Customer.class);
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
Customer customer = (Customer) jaxbUnmarshaller.unmarshal(file);
System.out.println(customer.name);
System.out.println(customer.string);
私の期待される出力は次のようになります
Sample
sample values
var
var value