2

Question

I have a simiar XML file stored in my physical drive , how i can create a new record using C# in this xml file ? , is it possible to do it with LINQ? or is there an any other method ?

[other method should not be read the whole file and concat and save back using a filestream]


Sample XML:

<products>
  <product>
    <id>1</id>
    <price>1150</price>
  </product>
</prodcuts>
Ben Robinson
  • 21,601
  • 5
  • 62
  • 79
Sudantha
  • 15,684
  • 43
  • 105
  • 161
  • 3
    Possibly duplicate of http://stackoverflow.com/questions/2131061/how-do-i-insert-an-element-into-xml-using-linq ? – Smudge202 Jun 27 '11 at 13:55

2 Answers2

1

Yes, it is.

There a great answer about the subject here: XDocument or XmlDocument.

Community
  • 1
  • 1
Adriano Carneiro
  • 57,693
  • 12
  • 90
  • 123
1

Yes it is posiible do with LINQ look at LINQ to XML

Sergey K
  • 4,071
  • 2
  • 23
  • 34