Search code examples
xmlconcatenationbiztalkbiztalk-2013c#-1.2

Concatenate in LoadXml() in expression shape with BizTalk


I'm pretty new with BizTalk and I have a problem with concatenation in BizTalk's Expression shape.

In this expression shape I have this code:

xmlBody = xpath(msgIN, "/*[local-name()='CatManager' and namespace-uri()='http://Manager.CatManager']/*[local-name()='Owners']/*[local-name()='Owner'][counterString]");
xmlTemp.LoadXml("<ns0:CatManager xmlns:ns0=\"http://Manager.CatManager\">" + xmlBody + "</ns0:CatManager>");
msgOUT = xmlTemp;

which is returning this error:

operator '+' cannot be applied to operands of type 'System.String' and 'System.Xml.XmlDocument'

So I'd try this:

xmlTemp.LoadXml("<ns0:CatManager xmlns:ns0=\"http://Manager.CatManager\">" + xmlBody.ToString() + "</ns0:CatManager>");

Or this:

xmlTemp.LoadXml("<ns0:CatManager xmlns:ns0=\"http://Manager.CatManager\">" + xmlBody.OuterXml + "</ns0:CatManager>");

But it doesn't work and I can't find a solution.


Solution

  • I find the problem. I just forgot to concatenate counterString in my xpath query.

    xmlBody = xpath(msgIN, "/*[local-name()='CatManager' and namespace-uri()='http://Manager.CatManager']/*[local-name()='Owners']/*[local-name()='Owner'][" + counterString + "]");