BizTalk Server General - Construct Using XPath

This is Interesting: Free IT Magazines  
Home > Archive > BizTalk Server General > February 2006 > Construct Using XPath





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Construct Using XPath
Jayendra

2006-02-26, 10:47 am

Hi,

I am using the following code to construct the new message,But it is not
constructed full message (NO Root Document Element) and it is having only
inner element details.Could any one pls look at it.[vbcol=seagreen]
Note:This is dummy code,jst to check message construction.

Construct EmpFinalMsg{
var_EmpMsg=EmpMsg;
strNode=(System.Xml.XmlNode)xpath(EmpMsg,"//*[local-name()='Employees' and
namespace-uri()='http://XPathFiltering.Employee']/*[local-name()='Employee'
and namespace-uri()='']");
strNode1=(System.Xml.XmlNode)xpath(EmpMsg,"//*[local-name()='Employees' and
namespace-uri()='http://XPathFiltering.Employee']");
strNode1=strNode1.ReplaceChild(strNode,strNode);
var_Final.LoadXml(strNode1.OuterXml);
System.Diagnostics.Debug.WriteLine("The output is " + var_Final.OuterXml);
EmpFinalMsg=var_Final;
}[vbcol=seagreen]
I/p and o/p obtaining are given below:

INput:
<ns0:Employees xmlns:ns0="http://XPathFiltering.Employee">
<Employee>
<Empl>
<EmpID>1</EmpID>
<EmpName>EmpName_0</EmpName>
</Empl>
<Empl>
<EmpID>2</EmpID>
<EmpName>EmpName_0</EmpName>
</Empl>
</Employee>
</ns0:Employees>

Output:

<Employee>
<Empl>
<EmpID>1</EmpID>
<EmpName>EmpName_0</EmpName>
</Empl>
<Empl>
<EmpID>2</EmpID>
<EmpName>EmpName_0</EmpName>
</Empl>
</Employee>


Thanks,Jay
BTSWizard

2006-02-26, 10:47 am

Hi Jay,

Instead of using XmlNode, and the replace method to get the outer
enclosing nodeset into the document. Load the var_Final XmlDocument
with the root element structure first, in this case the Employees node,
and then append the Employee node to that.

HTH,

Curt Peterson
v-cupete@microsoft.com

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com