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,319
  • 5
  • 61
  • 78
Sudantha
  • 14,804
  • 42
  • 102
  • 158
  • 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
  • 55,739
  • 12
  • 86
  • 122
1

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

Serghei
  • 3,861
  • 2
  • 20
  • 34