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.IO;
- using System.Xml.Linq;
- using System.Xml;
- namespace Xml36
- {
- class Program
- {
- static void Main(string[] args)
- {
- XDocument xdoc = XDocument.Load("Wrd.xml");
- //IEnumerable<XElement> mas = from elm in xdoc.Root.Descendants() where el.Parent.Name == xdoc.Root.Name select elm;
- IEnumerable<XElement> mas = from ele in xdoc.Root.Descendants() select ele;
- foreach (XElement ele in mas)
- {
- try
- {
- if (ele.Parent.Parent.Name == xdoc.Root.Name)
- {
- {
- int n = 0;
- Console.WriteLine(ele.ToString());
- IEnumerable<XElement> mas3 = from elem in ele.Descendants() select elem;
- foreach (XElement elem in mas3)
- {
- n++;
- }
- XAttribute ndct = new XAttribute("node-count", n);
- ele.Add(ndct);
- }
- }
- }
- catch { }
- }
- xdoc.Save("wrdd.xml");
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement