如何将此数据表转换为XML

时间:2011-10-28 06:29:23

标签: xml jaxb xsd

有两个数据表,其中包含有关文件目录结构的信息。我只想将其转换为最适合快速和最佳的XML。有效的解析。

enter image description here

表1中的

,客户端是根目录& project是客户端(根目录)中的文件夹Name,根目录(客户端)中可以有一个或多个文件夹。

e.g. D:\C1\P1\  /* here D:\ is the local disk */
     D:\C1\P2\ 
表2中的

表示隐藏的根目录(客户端)和文件中的文件。文件夹(项目),一个文件夹中可以有很多文件。

e.g. D:\C1\P1\F1  /* F1 is the file name */  

以下是客户端(C1),项目(P1)&的示例xml。现有文件(F1& F2)。请看看它是否可以定义更好的方法,请更正。

<root>
     <client>
          <id>C1</id>
          <project>
              <project-name>P1</project-name>
              <fileName>
                 <file>F1</file>
                 <file>F2</file>
               </fileName>
           </project>
     </client>
 </root>

*注意:* 我正在使用jaxb to marshall & unmarshall xml文件。

1 个答案:

答案 0 :(得分:0)

  1. 编写映射表结构的java类
  2. 将表记录加载到java对象
  3. 使用jaxb xml序列化程序生成xml文件
相关问题