我正在模仿一个大型 xml 文件,我愿意将其导入 mediawiki。文件已完成,但<text>content</text>
仍有剩余内容<
,>
我必须先编码。
我希望可以使用正则表达式完成编码步骤(我使用的是 Windows 和软件,如 sublime text 或编辑板或 vim)。我也应该能够运行 php 脚本。
使用({{word)(.*?)(?=</text>)
我能够选择所有目标进行替换——因为我不想对 xml 标记本身进行编码——但我不知道如何完成这项艰巨的工作,即如何替换所有位于目标明确的文本中的 < 和 >。
为了更清楚,这里是我需要编码几个字符的内容的简单摘录(我在 30 mo 文件中有 50000 个类似的内容):
<page>
<title>Title:75002</title>
<ns>510</ns>
<id>21</id>
<revision>
<id></id>
<parentid></parentid>
<timestamp>2015-1-5T14:49:09Z</timestamp>
<contributor>
<ip>0:0:0:0:0:0:0:1</ip>
</contributor>
<text xmlspace="preserve" bytes="345">{{word
| vedette ={{{vedette}}}
| id ={{ROOTPAGENAME}}
| vedette =boutique, with forbidden > and
evil < multiline
<!-----------encyclo---------->
| étymologie = still have sometimes a messing >
and maybe a < more.
<!-----------relations-------->
| synonyme ={{AutoLienSyno | }}
}}</text>
<sha1></sha1>
<model>wikitext</model>
<format>text/x-wiki</format>
</revision>
</page>
谢谢你。