Details
Description
XML
=====
<Config>
<name>XXX</name>
<xslConfig>
<reportFormat>
<fileName>test.xsl</fileName>
<dir>H:\xml\data\xsl\</dir>
</reportFormat>
<reportFormat>
<fileName>pdf_cp.xsl</fileName>
<dir>H:\xml\data\xsl\</dir>
</reportFormat>
</xslConfig>
</Config>
Code
======
public class Config
{
private String name = null;
private XSLConfig xslConfig = null;
public class XSLConfig
{
ReportFormat reportFormat;
XSLConfig(ReportFormat reportFormat)
public ReportFormat getReportFormat()
{ return reportFormat; }public void setReportFormat(ReportFormat reportFormat)
{ this.reportFormat= reportFormat; } }
public class ReportFormat
{
String fileName = null;
String dir = null;
ReportFormat(String fileName, String dir)
{ this.dir = dir; this.fileName = fileName; }public String getDir()
{ return dir; }public String getFileName()
{ return fileName; }public void setDir(String dir)
{ this.dir = dir; }public void setFileName(String fileName)
{ this.fileName = fileName; }}
public String getName()
{ return name; }public void setName(String name)
{ this.name = name; } public static void main(String[] arg)
{
BufferedReader reader = new BufferedReader(new FileReader(xmlFile));
String lineText;
while ((lineText = reader.readLine()) != null)
reader.close();
XStream stream = new XStream(new DomDriver());
stream.setMode(XStream.NO_REFERENCES);
Config config = (Config) stream.fromXML(xmlString);
System.out.println(config);
}
}
I keep getting DuplicateFieldException . Could you pls advise. Thanks.
Please use the user's list to ask questions.