BizTalk 脚本 Functoid 的内联 C#

In-line C# for BizTalk Scripting Functoid

对于下面的 XML,我如何在脚本 functoid 中使用内联 C# 来获取元素 = 'SAON' 的类型的值? 有关信息,这是来自我的源模式中的记录,该记录包含编码的 XML,我首先将其转换为 XML 文档。

<?xml version="1.0"?>
<LocationXML>
      <Location>
         <Element>PAON</Element>
         <type>a</type>
      </Location>
      <Location>
         <Element>SAON</Element>
         <type>b</type>
      </Location>
</LocationXML>

内联 C#:这来自我之前构建的应用程序,尚未在地图中进行测试,但我怀疑它距离不到一百万英里。

string s = NewValueXml;

 XmlDocument x = new XmlDocument();
 x.LoadXml("<root>" + s + "</root>");
return x.InnerText;

好的,在您用来将 string 转换为 xmldocument 的脚本 functoid 中,我会这样做,然后将 return 转换为 string,然后将其映射到您的目标节点。希望这次我理解了你的问题...

public string XMLConvertAndReturnType(string param1)
{
     string returnType = ""; //or String.Empty
     XmlDocument x = new XmlDocument();
     x.LoadXml("<root>" + param1 + "</root>");
     returnType = x.SelectSingleNode("//Location[Element = 'SAON']/type/text()").Value.ToString();
     return returnType; 
}