• Log in or sign up for an account here: https://www.sythe.org/login

cegonsoft coimbatore | LINQ to XML

danhar09

Newcomer
Joined
Sep 10, 2011
Sythe Gold
0
Messages
2
Consider that we want to create the following XML Document:

<?xml version="1.0"? encoding="utf-8">

<!–Xml Document–>

<catalog>

<book id="bk001">

<title>Book Title</title>

</book>
</catalog>
</xml>

Here is how we create the same XML document using Linq to Xml classes available in the System.Xml.Linq namespace:

XDocument doc =
new XDocument(
new XDeclaration("1.0", Encoding.UTF8.HeaderName, String.Empty),
new XComment("Xml Document"),
newXElement("catalog",
new XElement("book",
newXAttribute("id", "bk001"),
newXElement("title", "Book Title")
)
)
);
doc.Save("sampleLinq.xml");

more information at Cegonsoft
 
Runescape Gamblingrunescape gambling
Back
Top