Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Xml.Linq;
- namespace xml
- {
- class Program
- {
- static XDocument Betoltes()
- {
- //XDocument.Load("workers.xml"); //local bin/debug
- return XDocument.Load("http://users.nik.uni-obuda.hu/siposm/db/workers.xml");
- }
- static void Main(string[] args)
- {
- XDocument allomany = Betoltes();
- var mailok = from x in allomany.Root.Descendants("person")
- select x.Element("email").Value;
- var tamasok = from x in allomany.Root.Descendants("person")
- where x.Element("name").Value.ToUpper().Contains("TAMÁS")
- select x.Element("name").Value;
- var polihisztorok = from x in allomany.Root.Descendants("person")
- where x.Element("rank").Value.Equals("polihisztor")
- select new
- {
- NEV = x.Element("name").Value,
- MAIL = x.Element("email").Value
- };
- var intezetek = from x in allomany.Root.Descendants("person")
- group x by x.Element("dept").Value into g
- select new
- {
- LETSZAM = g.Count(),
- INTEZET = g.Key
- };
- XElement uj = new XElement("person",
- new XElement("name","ULTRON"),
- new XElement("email", "U@MAIL.HU"),
- new XElement("dept", "AII")
- //----
- );
- allomany.Root.Add(uj);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement