SSIS Web 服务任务 returns 包含“<”、</Value> 字符的文件文件

SSIS Web Service Task returns a file file with "&lt;", &lt;/Value&gt; characters

我有一个简单的 ssis 包,它将 Web 服务方法的结果保存到 XML 文件。 连接正常,正在创建文件,但包含 &lt;&gt; 标记而不是 <> .

如何替换此标签以更正?

主要问题是您将 Web 服务中的 xml 作为字符串传递 (不推荐)

你必须将 web 方法更改为 return 和 XmlDocument,将格式正确的 xml 加载到其中,并将其传回 SSIS。

或者你可以做一个小的解决方法是在保存 xml 文件后 运行 脚本并将 &lt; 替换为 < 并将 &gt; 替换为>

有用的链接

  • Decode XML returned by a webservice (< and > are replaced with &lt; and &gt)?
  • How to decode string to XML string in C#
  • Why are my "<br />" tags getting converted to "&lt;br /&gt;"?
  • SSIS 2005 mangling input XML from web service

也是选项之一

    Dim fileFirst As String = Dts.Variables("User::FullFilePath").Value.ToString()
    File.WriteAllText(fileFirst, File.ReadAllText(fileFirst).Replace("&lt;", "<"))

    Dim fileSecond As String = Dts.Variables("User::FullFilePath").Value.ToString()
    File.WriteAllText(fileSecond, File.ReadAllText(fileSecond).Replace("&gt;", ">"))

    Dim fileThird As String = Dts.Variables("User::FullFilePath").Value.ToString()
    File.WriteAllText(fileThird, File.ReadAllText(fileThird).Replace("&amp;", "&"))

    Dim fileFour As String = Dts.Variables("User::FullFilePath").Value.ToString()
    File.WriteAllText(fileFour, File.ReadAllText(fileFour).Replace("&quot;", "\"))

    Dim fileFive As String = Dts.Variables("User::FullFilePath").Value.ToString()
    File.WriteAllText(fileFive, File.ReadAllText(fileFive).Replace("&apos;", "'"))

使用脚本任务 -> VB