问问题
277 次
1 回答
2
如果您确定所有内容<title>this title</title>
都在单行上,请尝试:
Get-ChildItem -recurse | % {
((Get-Content .\test.xml) -match "<title>" -replace '<title>' -replace '</title>').Trim()
} | Set-Content protid_output.txt
如果他们更像:
<?xml version="1.0" encoding="ISO-8859-1"?>
<example>
<title>
protein name
</title>
</example>
然后尝试首先将其解析为 xml-object(更易于阅读),但避免使用 10+ MB 文件。例子:
Get-ChildItem -Recurse | % {
$x = [xml](Get-Content $_)
$x.example.title.Trim()
} | Set-Content protid_output.txt
于 2013-04-10T18:17:01.020 回答