Home| Progetto| Web| Faq| Acronimi | ||||
Argomenti Documenti pubblicabili:1120
Scripts:1282 Documenti non pubblicabili:162 Categorie tematiche:68 .Net |_C# |_Visual basic.net |_Asp.net Active Server Pages C++ Cascade Style Sheet JavaScript Mysql Php Xml Java |_Java 2 Micro Edition |_Java server pages |_Java Servlet Oracle |_PLSQL PostgreSQL Unix
C#...
Info:
C# Processo di compilazione
Oracle...
Script:
Opzione DEFAULT per il valore di una colonna
Unix...
Tip:
Rimuovere un file in Unix / Delete a file
PLSQL...
Script:
How to store in a variable execute immediate results
C#...
Tip:
Rendere invisibile una voce di menu
Shell scripting...
Script:
Formatting text as bold withing shell script
Basically, a web session can be defined as the timeframe in which a visitor navigates your web site.
Php Funzione mail()
XPath is a language for addressing parts of an XML document.
It is designed to be used by XSLT and XPointer.
Basically, a web session can be defined as the timeframe in which a visitor navigates your web site.
|
C#
Home >C# > Leggere Xml in un'applicazione windows
PrerequesitiPer questo tutorial occorre almeno una conoscenza di base del linguaggio C#.ObiettiviQuesto programma è un esempio che illustra come: 1) Caricare in un DataSet dei dati da un file xml;2) Visualizzare i dati nel DataGrid collegato al DataSet; 3) gestire eventuali eccezioni di caricamento del file xml o della validità del suo formato; ![]() Una volta compilato, l'applicazione tenterà di caricare i dati nel file c:\\libri.xml pertanto accertarsi di avervi copiato il file. Il file XmlDataGrid.zip contiene i file con il codice, i dati xml e un eseguibile già compilato. Segue il codice sorgente del file Form1.cs
/*
file Form1.cs
Rome 2004-03-11
www.fishscript.com If you do not have Visul Studio you may compile this application just with the .NET Framework (that you can dowload freely at Microsoft). 1) Make sure you have installed the .Net Framework (otherwise download it) 2) go C:\WINDOWS\Microsoft.NET\Framework\v1.0.XXXXX 3) Copy the readXml.cs in the above directory 4) From dos shell run the .Net C# compiler: csc /t:winexe Form1.cs */ using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using System.IO; using System.Xml; public class Form1 : System.Windows.Forms.Form { // componenti DataGrid, DataSet private System.Windows.Forms.DataGrid dataGrid1; DataSet dsBollettino = new DataSet("notizie"); private System.ComponentModel.Container components = null; private System.Windows.Forms.Button btnChiudi; // file xml valido da caricare string filePath = "c:\\libri.xml"; public Form1() { InitializeComponent(); } protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows Form Designer generated code private void InitializeComponent() { this.dataGrid1 = new System.Windows.Forms.DataGrid(); this.btnChiudi = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit(); this.SuspendLayout(); // // dataGrid1 // this.dataGrid1.CaptionFont = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.dataGrid1.DataMember = ""; this.dataGrid1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText; this.dataGrid1.Location = new System.Drawing.Point(8, 8); this.dataGrid1.Name = "dataGrid1"; this.dataGrid1.Size = new System.Drawing.Size(592, 168); this.dataGrid1.TabIndex = 4; // // btnChiudi // this.btnChiudi.Location = new System.Drawing.Point(280, 184); this.btnChiudi.Name = "btnChiudi"; this.btnChiudi.Size = new System.Drawing.Size(75, 24); this.btnChiudi.TabIndex = 10; this.btnChiudi.Text = "Chiudi"; this.btnChiudi.Click += new System.EventHandler(this.button4_Click); // // Form1 // this.AutoScaleBaseSize = new System.Drawing.Size(6, 16); this.ClientSize = new System.Drawing.Size(606, 212); this.Controls.AddRange(new System.Windows.Forms.Control[] { this.btnChiudi, this.dataGrid1} ); this.Font = new System.Drawing.Font("Arial", 10F); this.ForeColor = System.Drawing.SystemColors.Desktop; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D; this.Location = new System.Drawing.Point(200, 100); this.Name = "Fishscript readXml"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "Xml DataGrid fishScript.com"; this.Load += new System.EventHandler(this.Form1_Load); ((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit(); this.ResumeLayout(false); } #endregion [STAThread] static void Main() { Application.Run(new Form1()); } private void Form1_Load(object sender, System.EventArgs e) { loadXmlData(); } // Bottone per uscire private void button4_Click(object sender, System.EventArgs e) { Application.Exit(); } private void loadXmlData() { // apre il file libri.xml e popola il dataset try { dsBollettino.ReadXml(filePath); dataGrid1.DataSource = dsBollettino; dataGrid1.DataMember = "libro"; // carica i dati dataGrid1.CaptionText = "Libri"; // a che serve } // gestione eccezioni (file non trovato o non valido) catch (Exception e) { MessageBox.Show("File non trovato on in formato non valido errore:" + e.ToString()); } } } Downloads: XmlDataGrid.zip ( 5 KB) ![]() Warning: include(ads/text468x15.html): failed to open stream: No such file or directory in D:\inetpub\webs\fishscriptcom\documents\view_document.php on line 131 Warning: include(): Failed opening 'ads/text468x15.html' for inclusion (include_path='.;C:\php\pear') in D:\inetpub\webs\fishscriptcom\documents\view_document.php on line 131 Tutorial ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Script ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Esercizi ![]() ![]() ![]() Comandi ![]() ![]() ![]() |
Cerca
C#...
Info:
How C# applications are compiled
A good scientist is a person with original ideas.
A good engineer is a person who makes a design that works with as few original ideas as possible. There are no prima donnas in engineering. Freeman Dyson A good scientist is a person with original ideas.
A good engineer is a person who makes a design that works with as few original ideas as possible. There are no prima donnas in engineering. Freeman Dyson
C#...
Info:
Il metodo Main()
C#...
Definizioni:
Namespace
Oracle...
Definizioni:
Schema
Shell scripting...
Script:
Compact if construct
fishScript.Com is accessible by Mobile access technology
as mobile phones, Palm and Pocket PC .
Nicoleta e Marco Magnani tutorial, examples, courses, esempi, corsi, esercizi, appunti vari Dottoressa Nicoleta Dragu Formatrice Docente Insegnante Mediatrice Culturale Dott. Marco Magnani Universita La Sapienza Roma Master Computer Science Hunter College New York , Data Base Administrator DBA oracle System architect |