Advertisement
Guest User

c# xml

a guest
Apr 8th, 2018
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using System.Xml;
  11.  
  12. namespace WindowsFormsApp1
  13. {
  14. /*
  15. XmlDocument midocxml = new XmlDocument();
  16. midocxml.Load(@"c:\milista.xml");
  17.  
  18. XmlNodeList personas = midocxml.GetElementsByTagName("personas");
  19. XmlNodeList lista = ((XmlElement)personas[0]).GetElementsByTagName("persona");
  20. foreach (XmlElement nodo in lista)
  21. XmlNodeList nNombre = nodo.GetElementsByTagName("nombre");
  22. XmlNodeList nApellido1 = nodo.GetElementsByTagName("apellido1");
  23. XmlNodeList nApellido2 = nodo.GetElementsByTagName("apellido2");
  24. XmlNodeList nTelefono = nodo.GetElementsByTagName("telefono");
  25. XmlNodeList nEmail = nodo.GetElementsByTagName("email");
  26. */
  27.  
  28. public partial class Form1 : Form
  29. {
  30. public Form1()
  31. {
  32. InitializeComponent();
  33. }
  34.  
  35. private void Form1_Load(object sender, EventArgs e)
  36. {
  37.  
  38. }
  39.  
  40. private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
  41. {
  42. XmlDocument XmlDocument = new XmlDocument();
  43. object midocxml = null;
  44. midocxml.Load("milista.xml");
  45.  
  46. XmlNodeList personas = midocxml.GetElementsByTagName("personas");
  47. XmlNodeList lista = ((XmlElement)personas[0]).GetElementsByTagName("persona");
  48. foreach (XmlElement nodo in lista)
  49. XmlNodeList nNombre = nodo.GetElementsByTagName("nombre");
  50. XmlNodeList nApellido1 = nodo.GetElementsByTagName("apellido1");
  51. XmlNodeList nApellido2 = nodo.GetElementsByTagName("apellido2");
  52. XmlNodeList nTelefono = nodo.GetElementsByTagName("telefono");
  53. XmlNodeList nEmail = nodo.GetElementsByTagName("email");
  54.  
  55. }
  56. }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement