xpath Function C#
Hi
with the following simple functions it is possible to execute an XPath query from an external class in order to have more control over the execution of the same query. This way you can replace the xpath (msg, "<query xpath") statement within orchestration.
public string getXpathValeStream (XmlDocument myXml, string xPathQuery)
{
XPathNavigator nav;
XPathDocument docNav;
string xPathVarCurrency;
string xPathVarRate;
MemoryStream xmlStream = new MemoryStream();
myXml.Save(xmlStream);
xmlStream.Flush();//Adjust this if you want read your data
xmlStream.Position = 0;
docNav = new XPathDocument(xmlStream);
nav = docNav.CreateNavigator();
xPathQuery = "xPathQuery";
string valueVarxPathQuery= nav.SelectSingleNode(xPathQuery).Value;
return valueVarxPathQuery;
}
public string getXpathVale (string xmlPath, string xPathQuery)
{
XPathNavigator nav;
XPathDocument docNav;
string xPathVarCurrency;
string xPathVarRate;
XmlDocument myXml = new XmlDocument();
myXml.Load(xmlPath);
MemoryStream xmlStream = new MemoryStream();
myXml.Save(xmlStream);
xmlStream.Flush();//Adjust this if you want read your data
xmlStream.Position = 0;
docNav = new XPathDocument(xmlStream);
nav = docNav.CreateNavigator();
xPathQuery = "xPathQuery";
string valueVarxPathQuery= nav.SelectSingleNode(xPathQuery).Value;
return valueVarxPathQuery;
}