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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Scott LysleRank #49 · 31K reputationPosted Apr 30, 2008, 2:35 AM EDT
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;
}