XML, valori che ritornano

se vi occorre recuperare un valore da un file xml ecco una routine c#

public string GetDecodifica(string Value, string XMLFilePathName, string XMLFileName, string Nodo )

{

   // istanzia XPath per navigare nei nodi del file xml

   XPathDocument xdoc = new XPathDocument(XMLFilePathName + XMLFileName);

   XPathNavigator xnav = ((IXPathNavigable)xdoc).CreateNavigator();

   XPathNodeIterator xiter = xnav.Select(Nodo);

   // Recupera da file xml il valore cercato

   while(xiter.MoveNext())

   {

      XPathNodeIterator xiterFields = xiter.Current.SelectDescendants(XPathNodeType.Element,false);

      while(xiterFields.MoveNext())

      {

         string cValue = Value;

         if(xiterFields.Current.Name==cValue) return xiterFields.Current.Value;

      }

   }

   return null;

}

posted @ giovedì 10 marzo 2005 03:16

Print
Comments have been closed on this topic.
«dicembre»
domlunmarmergiovensab
24252627282930
1234567
891011121314
15161718192021
22232425262728
2930311234