将文本文件的内容包含在元素标签中并将输出写入 XML 文件

Enclosing the content of a text file in element tags and writing the output to an XML file

如何在文本文件的内容前添加开始标记,在其后附加结束标记并在命令行中将输出重定向到 XML 文件?

对于 DOS:

echo "<tag>"  > file.xml
type file.txt >> file.xml
echo "</tag>" >> file.xml

> 将创建文件,如果文件存在则将其截断,>> 将追加到文件中。