Fabio Carucci's WebLogs

"...You may say I'm a dreamer, but I'm not the only one..." (Imagine)
posts - 50, comments - 39, trackbacks - 7

My Links

News



PER CONSULENZE SCRIVERE SU "CONTACT"

Contattami se sono online!

This is my personal blog. These postings are provided "AS IS" with no warranties, and confer no rights. The views expressed on this weblog are mine alone and do not necessarily reflect the views of my employer.








View Fabio Carucci's profile on LinkedIn

Vuoi ricevere i miei post nella tua email? Iscriviti

Add to Technorati Favorites



http://www.csthota.com/blogmap/



Locations of visitors to this page





Tag Cloud

Archives

Post Categories

1 - Pubblicazioni

2 - Conferenze

3 - Links

4 - Blogs

marzo 2005 Entries

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 1.16 | Feedback (0) | Filed Under [ Visual C# ]

"C'era una volta un dataset" - svolgimento...

...dopo parecchio silenzio.... se può servire a qualcuno ecco una routine c# che "svolge" un dataset di qualsiasi dimensione e ne scrive il contenuto in un file testuale.   public void WriteToTxt(DataSet myDataset, string pathFileName, string fileNameStartWith) {     string file = String.Format("{0}{1}{2}.txt", pathFileName, fileNameStartWith, DateTime.Now.ToString("dd-MM-yyyy_HH.mm.ss"));     TextWriter tw = File.CreateText(file);     foreach (DataTable dt in myDataset.Tables)    {        foreach (DataRow dr in dt.Rows)       {           for (int i=0; i<=(dr.ItemArray.Length-1); i++) tw.Write(dr[i].ToString());           tw.WriteLine();       } } tw.Close(); }  

posted @ giovedì 10 marzo 2005 1.04 | Feedback (1) | Filed Under [ Visual C# ]

Powered by: