datasets & xmlhttp?

S

sfslug

Hello. I'm using xmlhttp in a windows application to return xml data.
The xml data is returned successfully, but I get errors when I try
loading the xmlhttp response object to a dataset. I can write the xml
to a file & read that in to a dataset, but what fun is that?
---------------
code:
xmlhttp = New MSXML2.XMLHTTP
xmlhttp.open("POST", strUrl, False)
xmlhttp.setRequestHeader("Content-Type", "text/xml")
xmlhttp.Send("...request ...")
Dim ds1 As New DataSet
ds.ReadXml(xmlhttp.responsexml.xml, XmlReadMode.Fragment)
---------------
the last line above, and any variations I've tried(xmlreadmode.auto,
etc.), all result in varying errors. This variation gives: "Illegal
characters in path."

Any insight appreciated.
 
D

David Browne

Hello. I'm using xmlhttp in a windows application to return xml data.
The xml data is returned successfully, but I get errors when I try
loading the xmlhttp response object to a dataset. I can write the xml
to a file & read that in to a dataset, but what fun is that?
---------------
code:
xmlhttp = New MSXML2.XMLHTTP
xmlhttp.open("POST", strUrl, False)
xmlhttp.setRequestHeader("Content-Type", "text/xml")
xmlhttp.Send("...request ...")
Dim ds1 As New DataSet
ds.ReadXml(xmlhttp.responsexml.xml, XmlReadMode.Fragment)
---------------
the last line above, and any variations I've tried(xmlreadmode.auto,
etc.), all result in varying errors. This variation gives: "Illegal
characters in path."

Any insight appreciated.

Why are you using (old) MSXML2.XMLHTTP instead of (new)
System.Net.WebClient?

David
 
C

Cor Ligthert [MVP]

Hi,

In addition to David.

A dataset in XML is a file using XML. Not every XML file is a dataset.

I hope this helps,

Cor
 
S

Slug

Hello. Thanks for the tips, but I'm not sure I'm any closer. I
changed the code to use the system.net.webclient, but the problem is
still in trying to load the response object into a dataset. Cor, I'm
not sure I fully understand your comment "not every xml file is a
dataset". Shouldn't I be able to make a dataset out of any valid xml?
David, I was using xmlhttp because I'm adapting this from an old asp
page, and that's what it used.

Here's the modified code I'm using.
-----------------
Dim objW3client As New System.Net.WebClient
objW3client.Headers.Set("Content-Type", "text/xml")
Dim bytArguments As Byte() =
System.Text.Encoding.ASCII.GetBytes(strMacro)
Try
Dim bytRetData As Byte() = objW3client.UploadData(strURL,
"POST", bytArguments)
Dim objInxText As String = ""
objInxText =
System.Text.Encoding.ASCII.GetString(bytRetData)
Dim ds As New DataSet
ds.ReadXml(objInxText)
 
C

Cor Ligthert [MVP]

Slug,
Shouldn't I be able to make a dataset out of any valid xml?

A normal dataset uses only elements. It has by instance no attributes.
Although that it in a lot of cases a dataset with attributes can be used to
read. (It converts than to a related XSD). However I did not really
investigate the last part when it does and when not.

I hope this gives an idea

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top