|
ms
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
XML => Object stored in memory?Seeking insight regarding which class/control/object is optimal to write XML
into and append with additional XML while the object is in memory? The XML must then be saved to disk and sorting by node(s) would be a real nice gift though not necessarily required. Hillbilly wrote:
> Seeking insight regarding which class/control/object is optimal to write XmlDocument class should be helpfull.> XML into and append with additional XML while the object is in memory? > The XML must then be saved to disk and sorting by node(s) would be a > real nice gift though not necessarily required. Its in the System.Xml namespace. DH "Hillbilly" <someb***@somewhere.com> wrote in message If you are using .NET 3.5 consider XDocument (System.Xml.Linq)news:eKitRCWYJHA.4272@TK2MSFTNGP03.phx.gbl... > Seeking insight regarding which class/control/object is optimal to write > XML into and append with additional XML while the object is in memory? The > XML must then be saved to disk and sorting by node(s) would be a real nice > gift though not necessarily required. Node creation is IMO easier and the coding of a sort will be no problem using a Linq query. -- Anthony Jones - MVP ASP/ASP.NET "Hillbilly" <someb***@somewhere.com> wrote in message You can use the StringBuilder to hold the XML in memory and append more XML.news:eKitRCWYJHA.4272@TK2MSFTNGP03.phx.gbl... > Seeking insight regarding which class/control/object is optimal to write > XML into and append with additional XML while the object is in memory? The > XML must then be saved to disk and sorting by node(s) would be a real nice > gift though not necessarily required. System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append("<?xml version=\"1.0\"?>\n"); sb.Append("<?mso-application progid=\"Excel.Sheet\"?>\n"); sb.Append( "<Workbook xmlns=\"urn:schemas-microsoft-com:office:spreadsheet\" "); sb.Append("xmlns:o=\"urn:schemas-microsoft-com:office:office\" "); sb.Append("xmlns:x=\"urn:schemas-microsoft-com:office:excel\" "); sb.Append("xmlns:ss=\"urn:schemas-microsoft-com:office:spreadsheet\" "); sb.Append("xmlns:html=\"http://www.w3.org/TR/REC-html40\">\n"); sb.Append("<DocumentProperties xmlns=\"urn:schemas-microsoft-com:office:office\">"); sb.Append("</DocumentProperties>"); sb.Append( "<ExcelWorkbook xmlns=\"urn:schemas-microsoft-com:office:excel\">\n"); sb.Append("<ProtectStructure>False</ProtectStructure>\n"); sb.Append("<ProtectWindows>False</ProtectWindows>\n"); sb.Append("</ExcelWorkbook>\n"); return sb.ToString(); You can then load the sb to a XMLdocument if you like. xmldocument doc = new xmldocment(); doc.LoadXML(sb.ToString()); You should be able to figure out how to save it from there. A sort on tags maybe asking too much. Insightful replies received here (TU) led me to discover these documents in
Aaron Skonnard's XML Best Practices Series... // Choosing an XML API http://support.softartisans.com/kbview.aspx?ID=673 // Reading XML Documents http://support.softartisans.com/kbview.aspx?ID=674 Show quoteHide quote "Hillbilly" <someb***@somewhere.com> wrote in message news:eKitRCWYJHA.4272@TK2MSFTNGP03.phx.gbl... > Seeking insight regarding which class/control/object is optimal to write > XML into and append with additional XML while the object is in memory? The > XML must then be saved to disk and sorting by node(s) would be a real nice > gift though not necessarily required.
Other interesting topics
Search all nodes using Linq
installer class failure Dynamically using object methods Transition from C# to VB.NET Second message loop a Windows Forms application? xml delegate parameter - can I do this? Filtering a XmlNodeList a simple linq query How to stop Invoked code running immediately after ShowDialog() closes |
|||||||||||||||||||||||