我正在尝试解组 xml 文件。下面是我的文件。
XML文件
<AccountInfo>
<Account>
<FirstName>FirstName1</FirstName>
<LastName>LastName1</LastName>
<Country>US</Country>
<PhoneNumber>2022023111</PhoneNumber>
<Email>test@test.com</Email>
<Password>1222433123</Password>
<PaymentMethod>
<CardNumber>4111111111111111</CardNumber>
<Month>12</Month>
<Year>2017</Year>
<CVV>098</CVV>
<StreetAddress>test</StreetAddress>
<Town>test</Town>
<State>Virginia</State>
<ZipCode>12365</ZipCode>
<Country>US</Country>
</PaymentMethod>
</Account>
<Account>
<FirstName>FirstName1</FirstName>
<LastName>LastName1</LastName>
<Country>US</Country>
<PhoneNumber>2022023111</PhoneNumber>
<Email>test@test.com</Email>
<Password>1222433123</Password>
<PaymentMethod>
<CardNumber>4111111111111111</CardNumber>
<Month>12</Month>
<Year>2017</Year>
<CVV>098</CVV>
<StreetAddress>test</StreetAddress>
<Town>test</Town>
<State>Virginia</State>
<ZipCode>12365</ZipCode>
<Country>US</Country>
</PaymentMethod>
</Account>
</AccountInfo>
Run Code Online (Sandbox Code Playgroud)
JaxbHelper.java
public static <T> T unmarshal(InputStream file, Class<T> unmarshalClass)
throws JAXBException {
JAXBContext jaxbContext = JAXBContext.newInstance(unmarshalClass);
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
T object = (T) jaxbUnmarshaller.unmarshal(file);
return object;
}
Run Code Online (Sandbox Code Playgroud)
账户信息.java
@XmlRootElement(name = "AccountInfo")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlSeeAlso({PaymentMethod.class})
public class …Run Code Online (Sandbox Code Playgroud) 通过MVC 5 HTML上传文件时是否可以完全删除"所有文件"下拉选项
@TempData ["fileType"]接受(.xml,.txt,.xml)它可以工作,但我想完全删除所有文件
<input type="file" name="file" accept="@TempData["fileType"]" />
Run Code Online (Sandbox Code Playgroud)
提前致谢.