i had on gateway.xml file,like
<
>
and i need to assign strUserID variable in .net,and i had to assign the
(strUserID =zoo) from the xml file....
Thanks in advance
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Scott LyslePosted Apr 30, 2008, 6:35 AM
Well, here is a quick way to get it with XPath; you could also look at something like LINQ to XML or modify this to pull back only a single value:
using System.Xml;
using System.Xml.XPath;
XmlDocument doc = new XmlDocument();
try
{
doc.Load(filePathToXml);
// get an xpath navigator
XPathNavigator navigator = doc.CreateNavigator();
// look for the path and use an iterator to capture the results
XPathNodeIterator nodes = navigator.Select(@“//GateWay/Collection/strpwd”);
while (nodes.MoveNext())
{
XPathNavigator node = nodes.Current;
yourVariable = node.InnerXml;
return;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error");
return;
}