cegonsoft coimbatore | LINQ to XML

Discussion in 'Web Programming' started by danhar09, Sep 10, 2011.

cegonsoft coimbatore | LINQ to XML
  1. Unread #1 - Sep 10, 2011 at 1:43 AM
  2. danhar09
    Joined:
    Sep 10, 2011
    Posts:
    2
    Referrals:
    0
    Sythe Gold:
    0

    danhar09 Newcomer

    cegonsoft coimbatore | LINQ to XML

    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
     
< Security in ASP.NET | cegonsoft coimbatore | Learn LINQ >

Users viewing this thread
1 guest


 
 
Adblock breaks this site