Textpipe批量替换XML标记,而不是内容 [英] Textpipe Batch replace XML tags, but not content

查看:140
本文介绍了Textpipe批量替换XML标记,而不是内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一组XML的,并希望更换所有的标签(包括嵌套的标签)用的,这样我可以在CSV查看作为现场每个标签之间的内容

I have a set of XMLs and want to replace all of the tags (including nested tags) with a , so that i can view the content between each and every tag as a field in a CSV

IE)

<name>John doe</name>

和我想只剩下

,John Doe,

有在XML文件中超过200个不同的标签,所以我不能查找和替换单个标签。

There are over 200 different tags in the xml files so i can't find and replace individual tags.

感谢您的帮助。

推荐答案

这是非常简单(快速)做你问什么用的常规EX pression搜索和替换工具像REPL.BAT

It is extremely simple (and fast) to do what you ask using a regular expression search and replace utility like REPL.BAT.

type file.xml | repl "<.*?>" "," >file.csv

但我怀疑的输出将是多大用处的。

But I doubt the output will be of much use.

您可以考虑只增加了结束标记一个逗号:

You might consider only adding a comma for closing tags:

type file.xml | repl "</.*?>" "," | repl "<.*?>" "" >file.csv

但我仍然怀疑这将是有益的。

But I still doubt it will be useful.

要做到一个文件夹结构中对所有.XML文件,上面的:

To do the above against all .XML files within a folder hierarchy:

for /r "c:\rootPath" %F in (*.xml) do type "%F" | repl "</.*?>" "," | repl "<.*?>" "" >"%~dpnF.csv"

更改所有 %% 如果一个批处理脚本中使用。

Change all % to %% if used within a batch script.

这篇关于Textpipe批量替换XML标记,而不是内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆