Unanswered Create XML using XmlTextWriter in c#?

  • Friday, January 04, 2013 5:31 AM
     
     

    Hi all ,

    i want to create XML like below using XmlTextWriter and also want to read using XmlTextReader in my C# application.

    <?xml version="1.0" encoding="utf-8"?>
    <VehicleDetail>
      <CAR>
        <Company>Ford</Company>
        <Model>Figo</Model>
        <CarNumber>RJ27-CB-8551</CarNumber>
        <Colour>White</Colour>
      </CAR>
      <BIKE>
        <Company>Bajaj</Company>
        <Model>Pulsur</Model>
        <BikeNumber>RJ27-SE-1551</BikeNumber>
        <Colour>Black</Colour>
        <CC>180</CC>
      </BIKE>
    </VehicleDetail>

    plsease help me to create and read this. :)

    thanks in advance :)


    sumitk

All Replies

  • Friday, January 04, 2013 1:57 PM
     
     

    Why XmlTextWriter? Since .NET 2.0 the recommended way is to use XmlWriter.Create, see http://msdn.microsoft.com/en-us/library/4d1k42hb.aspx.

    And XmlWriter and XmlReader are low level APIs, it is much easier and more comfortable to handle such small sized XML documents with LINQ to XML (.NET 3.5 or later) or XmlDocument (in earlier .NET versions).


    MVP Data Platform Development My blog