我正在编写一个应用程序,它必须根据目录中的一组文件更新已存在的xml文件的各个部分。此XML文件的一个例子在下面可以看到:在运行时将节点添加到xml中?
http://izpack.org/documentation/sample-install-definition.html
在以下范围的文件的列表,并将其指定的,如果他们应该是“可解析”(用于参数替代):
<packs>
<pack name="Main Application" required="yes" installGroups="New Application" >
<file src="post-install-tasks.bat" targetdir="$INSTALL_PATH"/>
<file src="build.xml" targetdir="$INSTALL_PATH"/>
<parsable targetfile="$INSTALL_PATH/post-install-tasks.bat"/>
<parsable targetfile="$INSTALL_PATH/build.xml"/>
</pack>
</packs>
现在,每次运行应用程序时,必须添加到此作用域的文件数量都会发生变化。为了使这成为可能,我考虑了以下方法:
1)将整个xml读入org.w3c.dom。*;根据读取目录的结果记录和添加节点。
2)以某种方式将内容从.properties文件添加到范围。这样可以在不重新编译代码的情况下更新文件列表。
3)??
任何有关这种任务的好方法的建议?