我有两个 xml 文件,一个名为 config.xml 和 configtemplate.xml。我想要做的是将 configtemplate.xml 中的行添加到 config.xml 文件中。
config.xml
<?xml version="1.0" encoding="utf-8"?>
<config>
<Database>
<DataType>1</DataType>
<ServerName>192.168.50.80</ServerName>
// add information here supplied by the configtemplate.xml
</Database>
<Services>
<Wash>1</Wash>
// add information here supplied by the configtemplate.xml
</Services>
<Options>
<TaxRate>8.125</TaxRate>
<AskForZipcode>0</AskForZipcode>
// add information here supplied by the configtemplate.xml
</Options>
我需要的是它从 configtemplate.xml 获取所有数据并将其添加到配置文件中,而不会覆盖它们中的值和值。
configtemplate.xml 中的值也将不同于它们可能拥有的值。
configtemplate.xml
<?xml version="1.0" encoding="utf-8"?>
<config>
<Database>
<DataType>1</DataType>
<ServerName>192.168.50.80</ServerName>
// add all lines below to config.xml
<DatabaseName>TestDB</DatabaseName>
</Database>
<Services>
<Wash>1</Wash>
// add all lines below to config.xmlxml
<Greeter>0</Greeter>
</Services>
<Options>
<TaxRate>8.125</TaxRate>
<AskForZipcode>0</AskForZipcode>
// add all lines below to config.xml
<AutoSave>1</AutoSave>
</Options>
我希望我能正确地自我解释,谢谢