JJKazJr Posted August 2, 2006 Posted August 2, 2006 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? Quote
Administrators PlausiblyDamp Posted August 2, 2006 Administrators Posted August 2, 2006 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. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
JJKazJr Posted August 2, 2006 Author Posted August 2, 2006 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. Quote
Administrators PlausiblyDamp Posted August 3, 2006 Administrators Posted August 3, 2006 My bad - didn't read all your post properly... http://robz.homedns.org:8080/blog/archive/2005/02/25/387.aspx looks like it might do what you want (and possibly a bit more). Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
JJKazJr Posted August 3, 2006 Author Posted August 3, 2006 Thank you. That link looks like it should do exactly what I wanted. Haven't tried it yet, but it looks like what I was looking for. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.