Reputation: 21
I want to unmarshall the below XML file
<uc-export clientvers="9.00">
<JOBS_WINDOWS AttrType="WINDOWS" client="0001" name="BEP.WIN.SRZ2AY" system="UC4_EXP">
<ATTR_JOBS state="1">
<AutoDeactNo>6</AutoDeactNo>
<ActAtRun>2</ActAtRun>
</ATTR_JOBS>
</JOBS_WINDOWS>
</uc-export>
want to get the value of in my java program. I have found a complex solution as of now if there any simple way to proceed rather than creating java class inside another java class.
Upvotes: 0
Views: 122
Reputation: 521194
You can try using JAXB Java Architecture for XML Binding. See here for an example.
Another option to consider is Apache XMLBeans. In XMLBeans, you would create an XSD file which the above XML you gave matches. XMLBeans would compile this XSD file and generate an XmlObject POJO corresponding to the XSD file. Let us call this class (interface) YourXMLDocument. Once these steps are out of the way, you can simply parse your input XML file ("input.xml") with the following line of code:
YourXMLDocument yourDoc = YourXMLDocument.Factory.parse("input.xml");
See here for more information.
Upvotes: 1