Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I currently have code written in vba to request a xml document from a url. This works fine, I am however looking to rewrite this code in vb.net. I know that I could accomplish this task by adding the COM reference Microsoft XML, v#.0, but I figure there has to be a way to do this in .nets native libraries.

 

I can create and read xmls this is not my question. My question deals specifically with the sending a request and recieve the xml file from a URL. I have seen familiar posts with peopel being confused with the question. In short I am wondering if there is a native way in .net to request a xml file from a url.

 

My current code looks like this: (from vba)

 

Dim xmlHttp As new ServerXMLHTTP50
xmlHttp.Open("POST",targetURL, False) 'targetURL is a string
xmlHttp.setRequestHeader("Content-Type", "text/xml")
xmlHttp.send request 'request is my request string

 

I would then get the file back from

xmlHttp.responseXML.XML

 

is there a better way to do this, or should I just use the Microsoft XML COM?

  • Administrators
Posted

Dim xr As New Xml.XmlTextReader(targetUrl)

 

would create an XmlReader object from the specified url and allow you walk over the nodes etc.

 

Dim xr As New Xml.XmlTextReader(targetUrl)
Dim doc As New Xml.XmlDocument()
doc.Load(xr)

would load the returned xml into a XmlDocument - the .Net equivalent of a DOMDocument.

 

If the xml is being returned from a web service then .Net provides an entire set of classes and framework objects for dealing with the remote server which may be worth looking at.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted
I am not entirely sure what the site I am connecting to is set up as, but it is not an xml document nor directly filled with the information that I want. I will need to pass a request xml string into it to get the xml that I want from it. Where in the textreader would I be doing that? I am pretty sure the site I am looking is not a web service although I am not too familiar with web services, I know a little though.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...