Windows批处理:读取XML格式化一个很长的行 [英] Windows Batch: Read a very long line from unformatted xml
问题描述
我如何使用批处理文件中读取一个很长的格式化XML的行?我试图插入后,每一个换行符>
问题是,我的批处理文件跳到下一行发现之后,>
而因为这种行为只显示我的XML文件的第一个标签(这里只有一条线,第二线不存在)。
这是我用过的命令:
FOR / Fdelims =>中%%我(的test.xml)DO @echo %%我
这是我的xml文件的外观的例子:
<简单类型名称=parseType><限制性基地=XS:令牌><枚举值=XML/<枚举值=TEXT />< /限制>< /简单类型>
这是cmd命令的输出:
<简单类型名称=parseType
这是做一个健全的方式处理很长的行:
键入file.txt的| REPL>中> \\ r \\ nXL>中newfile.txt
本使用名为 repl.bat
(由dbenham)的辅助批处理文件 - 下载来自:的 https://www.dropbox.com/s/qidqwztmetbvklt/repl.bat
将 repl.bat
在同一文件夹中的批处理文件或者是道路上的一个文件夹中。
How can I use a batch file to read a very long line of unformatted xml? I'm trying to insert a line break after every ">".
The problem is, that my batch file skips to the next line after it finds a ">".
And because of this behaviour only the first tag of my xml file is displayed (there's only one line, a second line does not exist).
This is the command that I've used:
FOR /F "delims=>" %%i IN (test.xml) DO @echo %%i
This is an example of how my xml file looks:
<simpleType name="parseType"><restriction base="xs:token"><enumeration value="xml"/<enumeration value="text"/></restriction></simpleType>
This is the output of the cmd command:
<simpleType name="parseType"
This is a robust way of doing it and handles very long lines:
type "file.txt" | repl ">" ">\r\n" XL >"newfile.txt"
This uses a helper batch file called repl.bat
(by dbenham) - download from: https://www.dropbox.com/s/qidqwztmetbvklt/repl.bat
Place repl.bat
in the same folder as the batch file or in a folder that is on the path.
这篇关于Windows批处理:读取XML格式化一个很长的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!