Just a quick question.
Other than the way you manipulate them, are XMLDocuments and DataSets basically the same thing? I'm just wondering for speed issues.
I have come across some code that calls dataSet.getXML() and then traverses the new XMLDocument.
I'm just curious what's the performance difference and which is the best one to use!
Thanks,
Adam
Very different.
A DataSet
is a collection of related tabular records (with a strong focus on databases), including change tracking.
An XmlDocument
is a tree structure of arbitrary data. You can convert between the two.
For "which is best".... what are you trying to do? Personally I very rarely (if ever) use DataSet
/ DataTable
, but some people like them. I prefer an object (class
) representation (perhaps via deserialization), but xml processing is fine in many cases.
It does, however, seem odd to write a DataSet
to xml and then query the xml. In that scenario I would just access the original data directly.
No they are not. A DataSet does not store its internal data in XML and than a XMLDocument does not use a table/row structure to store XML Elements. You can convert from one to the other within severe limits but that's it. One of the biggest limitations is that a DataSet requires data to fit in a strict Table/Column format where a XmlDocument can have a wildly different structure from one XmlElement to the next. Moreover, the hierarchical structure of a XmlDocument usually doesn't map well to the tabular structure of a DataSet.
.NET provides XmlDataDocument as a way handle XML data in a tabular way. You have to remember though that XmlDataDocument is an XmlDocument first. The generated DataSet is just an alternative and limited way to look at the underlying XML data.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With