Howdy,
I'm using VB.Net 2.0. Is there an easy object to use to handle XML?
Basically, i am collecting a ton of info from SQL, from various
Tables/Views/Procs, adding some data on the fly then I need to output the
entire thing to XML. I know i can create a string object and simply create
an XML string but that's messy. I know there's a XMLDocument object but I
can't seem to get it to work. Ideally, i'd like to have an XML object of
some sort and then work through it's elements/nodes and populate the
information as needed. If you could provide some sample script that'd be
great.
Thanks!
David Lozzi
sloan - 27 Sep 2007 20:12 GMT
To write xml, look at the XmlWriter
http://www.c-sharpcorner.com/UploadFile/mahesh/writexmlusingXmlWriter11132005233
450PM/writexmlusingXmlWriter.aspx
or google it.
I think it is your "lightest weight" object for writing needs.
If you have an EXISTING xml doc, then you need to use the XmlDocument,
because you'll have to use something like
SelectNodes
SelectSingleNode
to navigate the tree, and find the correct place to insert/update data.
> Howdy,
>
[quoted text clipped - 10 lines]
> Thanks!
> David Lozzi
IfThenElse - 27 Sep 2007 20:14 GMT
If you manipulated data can end in a DataSet then
Dim YourDataSetThatHasAllTheMinipulatedData as
System.Data.DataSet
YourDataSetThatHasAllTheMinipulatedData.WriteXml("XMLFile.xml")
This might help you?
> Howdy,
>
[quoted text clipped - 10 lines]
> Thanks!
> David Lozzi
IfThenElse - 27 Sep 2007 20:17 GMT
http://www.aspnettutorials.com/tutorials/database/XML-vb.aspx
> Howdy,
>
[quoted text clipped - 10 lines]
> Thanks!
> David Lozzi
Alexey Smirnov - 27 Sep 2007 20:36 GMT
> Howdy,
>
[quoted text clipped - 10 lines]
> Thanks!
> David Lozzi
e.g. XmlTextWriter
StringWriter sw = new StringWriter();
XmlTextWriter writer = new XmlTextWriter(sw);
writer.WriteStartElement("...");
writer.WriteEndElement();
writer.Flush();
writer.Close();
sw.Close();