vb.net - Saving the result of a linq query to an XML file -


here original xml file

<?xml version="1.0" encoding="utf-8"?> <configuration>     <setup>         <cap>33</cap>     </setup>     <setup>         <cap>dd</cap>     </setup> </configuration> 

in example below delete node cap equals 33

dim cap integer = 33 dim query = q in xelement.load(environment.currentdirectory & "\sample.xml").elements("setup") _             q.value = cap _             select q each q in query     if cap = q.element("cap").value q.remove() next 

now how can write result of query .xml file? like...

<?xml version="1.0" encoding="utf-8"?> <configuration>     <setup>         <cap>dd</cap>     </setup> </configuration> 

well, can create new xdocument data. (c# syntax, converted...)

xdocument doc = new xdocument(new xelement("configuration", query)); doc.save(file); 

Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -