我有一个大型 XML 文件,我想剥离所有标签并只保留节点值。我希望每个节点值都在单独的行中。我怎样才能做到这一点?
我可以使用免费软件还是使用 PHP 或 ASP.NET 代码。我还查看了 XSLT 选项。RegEX 可能太多了。我探索了查看simplexml_load_file()
,的 PHP 选项strip_tags()
,get_file_contents()
但失败了。
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- a comment -->
<catalog>
<cd>
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist>
<country>USA</country>
<company>Columbia</company>
<price>10.90</price>
<address>
<city>Melbourne </city>
<zip>01803 </zip>
</address>
<year>1985</year>
</cd>
<cd>
<title>Hide your heart</title>
<artist>Bonnie Tyler</artist>
<country>UK</country>
<company>CBS Records</company>
<price>9.90</price>
<year>1988</year>
</cd>
</catalog>
编辑:这是我尝试过的,除其他外。
<?php
$xml = simplexml_load_file('myxml.xml');
echo strip_tags($xml);
?>