using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Xml; namespace xmlreader { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { XmlTextReader cti = new XmlTextReader("C:/soubor.xml"); while (cti.Read()) { listBox1.Items.Add(cti.NodeType.ToString() + "-" + cti.Depth.ToString()); if (cti.NodeType == XmlNodeType.Text) listBox2.Items.Add(cti.Value); else listBox2.Items.Add(cti.Name + " - "); } } private void listBox1_SelectedIndexChanged(object sender, EventArgs e) { listBox2.SelectedIndex = listBox1.SelectedIndex; } private void listBox2_SelectedIndexChanged(object sender, EventArgs e) { listBox1.SelectedIndex = listBox2.SelectedIndex; } private void button2_Click(object sender, EventArgs e) { XmlTextReader cti = new XmlTextReader("C:/soubor.xml"); while (cti.Read()) { if (cti.MoveToContent() == XmlNodeType.Element) for (int i = 0; i < cti.AttributeCount; i++) { listBox3.Items.Add(cti.Name+" - "+cti.GetAttribute(i)); } } } } }