Exemplo n.º 1
0
        static void Main()
        {
            XDocument xmlDocument = new XDocument(
                new XDeclaration("1.0", "utf=8", "yes"),
                new XComment("Creating an XML Tree using LINQ to XML"),
                new XElement("SteelMembers",

                             from steelmembers in SteelMember.GetSteelMembers()
                             select new XElement("SteelMember", new XAttribute("Id", steelmembers.Id),
                                                 new XElement("Profile", steelmembers.Profile),
                                                 new XElement("Primer", steelmembers.Primer),
                                                 new XElement("Length", steelmembers.Length))));


            xmlDocument.Save(@"C:\Users\brung\Desktop\Programming\Software Development\C#\C#\Linq XML\linqBeam\linqBeam\Steel.xml");
        }
Exemplo n.º 2
0
        public static SteelMember[] GetSteelMembers()
        {
            SteelMember[] steelmembers = new SteelMember[4];

            steelmembers[0] = new SteelMember {
                Id = 101, Profile = "W12X10", Primer = "Red", Length = 120.68
            };
            steelmembers[1] = new SteelMember {
                Id = 102, Profile = "L5X5X3/8", Primer = "Grey", Length = 206.75
            };
            steelmembers[2] = new SteelMember {
                Id = 103, Profile = "C10X15.3", Primer = "Red", Length = 72.88
            };
            steelmembers[3] = new SteelMember {
                Id = 104, Profile = "W12X18", Primer = "Black", Length = 468.38
            };

            return(steelmembers);
        }