XElement.Save(String fileName) : XElement « System.Xml.Linq « C# / C Sharp by API






XElement.Save(String fileName)

   


using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Linq;
using System.Reflection;
using System.Xml.Linq;

class Program {
    static void Main(string[] args) {
        XElement xml = XElement.Load("Employee.xml");
        XElement html = new XElement("HTML",
                                new XElement("BODY",
                                    new XElement("TABLE",
                                        new XElement("TH", "ID"),
                                        new XElement("TH", "Full Name"),
                                        new XElement("TH", "Role"),
                                            from p in xml.Descendants("person")
                                            join r in xml.Descendants("role") on (int)p.Element("idrole") equals (int)r.Element("id")
                                            select new XElement("TR",
                                                            new XElement("TD", p.Element("id").Value),
                                                            new XElement("TD", p.Element("firstname").Value + " " + p.Element("lastname").Value),
                                                            new XElement("TD", r.Element("roledescription").Value)))));

        html.Save(@"C:\People.html");
    }
}

   
    
    
  








Related examples in the same category

1.new XElement
2.XElement.AddFirst
3.XElement.Ancestors()
4.XElement.AncestorsAndSelf()
5.XElement.AncestorsAndSelf(String tagName)
6.XElement.Attribute
7.XElement.Changed
8.XElement.Changing
9.XElement.Descendants
10.XElement.Descendants("firstname").First()
11.XElement.Elements
12.XElement.First
13.XElement.FirstAttribute
14.XElement.GetSchemaInfo()
15.XElement.HasAttributes
16.XElement.HasElements
17.XElement.Load(String fileName)
18.XElement.Nodes()
19.XElement.Parent
20.XElement.Parse(String xml value)
21.XElement.Remove
22.XElement.RemoveAll
23.XElement.SetAttributeValue
24.XElement.SetElementValue