Reading XML String into DataSet (VB.NET)
-
Heya, I'm having a bit of a problem. I have a XML string which I can read into an XML Document but I can't figure out how to get the data into a DataSet :-O. The dataset is looking for a stream or xmlreader and I'm not a 100% sure on how these work... Any help would be appreciated thanks :)
The man who smiles when things go wrong has thought of someone he can blame it on. If you tell a man there are 300 billion stars in the universe, he'll believe you. But if you tell him a bench has just been painted, he'll have to touch it to be sure.
-
Heya, I'm having a bit of a problem. I have a XML string which I can read into an XML Document but I can't figure out how to get the data into a DataSet :-O. The dataset is looking for a stream or xmlreader and I'm not a 100% sure on how these work... Any help would be appreciated thanks :)
The man who smiles when things go wrong has thought of someone he can blame it on. If you tell a man there are 300 billion stars in the universe, he'll believe you. But if you tell him a bench has just been painted, he'll have to touch it to be sure.
This code works for me: In my app oResultsNode is the document element of an xml document. Private Function GetResults(ByVal oResultsNode As XmlNode) As DataSet If Not oResultsNode Is Nothing Then Dim dsResults As New DataSet Dim oXmlNodeReader As New XmlNodeReader(oResultsNode) dsResults.ReadXml(oXmlNodeReader, XmlReadMode.InferSchema) Return dsResults End If End Function Jim
-
Heya, I'm having a bit of a problem. I have a XML string which I can read into an XML Document but I can't figure out how to get the data into a DataSet :-O. The dataset is looking for a stream or xmlreader and I'm not a 100% sure on how these work... Any help would be appreciated thanks :)
The man who smiles when things go wrong has thought of someone he can blame it on. If you tell a man there are 300 billion stars in the universe, he'll believe you. But if you tell him a bench has just been painted, he'll have to touch it to be sure.
Dim vReader As New IO.StringReader(vString) Dim vSet as new DataSet() vSet.ReadXml(vReader) :) Free your mind...
-
This code works for me: In my app oResultsNode is the document element of an xml document. Private Function GetResults(ByVal oResultsNode As XmlNode) As DataSet If Not oResultsNode Is Nothing Then Dim dsResults As New DataSet Dim oXmlNodeReader As New XmlNodeReader(oResultsNode) dsResults.ReadXml(oXmlNodeReader, XmlReadMode.InferSchema) Return dsResults End If End Function Jim
Cool thanks, I'll give it a try :)
The man who smiles when things go wrong has thought of someone he can blame it on. If you tell a man there are 300 billion stars in the universe, he'll believe you. But if you tell him a bench has just been painted, he'll have to touch it to be sure.
-
Dim vReader As New IO.StringReader(vString) Dim vSet as new DataSet() vSet.ReadXml(vReader) :) Free your mind...
:doh: And here I was trying to get the XmlParserContext, XMLReader and XMLNamespaceManager to all talk to each other... (it eventually worked but my lordy it was NOT pretty) Thanks man, I'll give it a try now :-D
The man who smiles when things go wrong has thought of someone he can blame it on. If you tell a man there are 300 billion stars in the universe, he'll believe you. But if you tell him a bench has just been painted, he'll have to touch it to be sure.