我正在尝试获取xml文件中node的值。我发现价值观是错误的。我相信问题出在编码上。有人能帮我吗?下面是我的代码:
在xml文件中:
<?xml version="1.0" encoding="UTF-8" ?>
<projects>
<project>
<application>Padrão</application> <!-- The problem is the character ~ -->
<name>padrao</name>
<icon>c:buffer</icon>
<market>br.com.tls.test</market>
</project>
</projects>
我的蚂蚁代码
<xmltask source="config.xml" encoding="UTF-8">
<call path="//project">
<param name="name" path="name/text()" />
<param name="market" path="market/text()" />
<param name="icon" path="icon/text()" />
<param name="application" path="application/text()" />
<actions>
<echo message="@{application}" />
<init-release name="@{name}" market="@{market}" icon="@{icon}" application="@{application}"/>
</actions>
</call>
</xmltask>
结果
[echo]: padr#o
预期
[echo]: padrão
解决方案
我将文件更改为UTF-8,并成功替换。
我没有使用xmltask,但echo task也有编码属性,你也尝试过设置吗?
例如<echo message="@{application}" encoding="UTF-8" />