简体   繁体   中英

Parsing and retrieving values from XML using java

My Sample XML:

 <Group-1>
   <One>
     <two>Name1</two>
     <three>Type1</three>
   </One>
   <One>
     <two>Name2</two>
     <three>Type2</three>
   </One>
 </Group-1>
 <Group-2>
   <One-2></One-2>
 </Group-2>

There are two XML different XML Parent tags in my XML. How can i retrieve the values from the above XML using XML parsers using core java? I have seen examples using getelementsbytagname("").But i need some method to retrieve all the values when there are many repeats and also for simple XML tags? Can anyone plz help me on this?

您需要使用JAXBContext marshall和unmarshall

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM