c# - What is the .Net 2.0 equivalent of xElement.Parse (string) -
i have code in c# .net 4.0 need work on computer functioning .net 2.0 framework. basically, read lines of data server. line looks this:
<rec cnt="5275" time="-66520.287" time_tick="0" fpogx="0.00000" fpogy="0.00000" fpogs="0.000" fpogd="0.000" fpogid="0"/>
i took these lines , added xml document using xelement.parse function. following disconnection, data saved.
xelement xmldoc = new xelement("data"); //dataline string obtained each iteration reading network stream xelement xmldataline = xelement.parse(dataline); xmldoc.add(xmldataline) while (!stopclient) xmldoc.save(filename)
how can in .net 2.0?
you best off using xmldocument
;
xmldocument doc = new xmldocument(); xmlelement root = (xmlelement)doc.appendchild(doc.createelement("data")); { string dataline = ...; using(xmlreader reader = xmlreader.create( new stringreader(dataline))) { root.appendchild(doc.readnode(reader)); } } while (!stopclient); doc.save(target);
Comments
Post a Comment