|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How to read XML data stream via a URL address into a string ?I know how to read XML from a file.
But I will need to load the XML content from a URL, so when I go to the URL, the result is XML file, and I will need to capture the content to a string. How can I do that ? Thank you. "fniles" <fni***@pfmail.com> wrote in message Set a reference to one of the Microsoft XML xxx libraries (preferably the news:eYMaSU2lJHA.1292@TK2MSFTNGP02.phx.gbl... >I know how to read XML from a file. > But I will need to load the XML content from a URL, so when I go to the > URL, > the result is XML file, and I will need to capture the content to a > string. > How can I do that ? newest you have) and then look at the XMLHTTPxx classes. They have to ability to send requests, i.e., get data from a URL, and then they'll have the result in one or more of their responsexxx properties. If you have the xml in a string you can use the DOMDocument's LoadXML
method. Show quoteHide quote "fniles" <fni***@pfmail.com> wrote in message news:eYMaSU2lJHA.1292@TK2MSFTNGP02.phx.gbl... >I know how to read XML from a file. > But I will need to load the XML content from a URL, so when I go to the > URL, > the result is XML file, and I will need to capture the content to a > string. > How can I do that ? > Thank you. > > "Bill McCarthy" <TPASoft.com Are Identity Thieves> wrote in message He doesn't have the XML. The question, as I understood it, was "How do I get news:OXUM0p7lJHA.4420@TK2MSFTNGP05.phx.gbl... > If you have the xml in a string you can use the DOMDocument's LoadXML > method. XML from a Web request?" "Jeff Johnson" <i.get@enough.spam> wrote in message Ah, yep I think you're right. I think for that I'd favor using the news:ua5MdBCmJHA.1172@TK2MSFTNGP04.phx.gbl... > "Bill McCarthy" <TPASoft.com Are Identity Thieves> wrote in message > news:OXUM0p7lJHA.4420@TK2MSFTNGP05.phx.gbl... > >> If you have the xml in a string you can use the DOMDocument's LoadXML >> method. > > He doesn't have the XML. The question, as I understood it, was "How do I > get XML from a Web request?" AsyncRead of a usercontrol class for simple urls, switching to the XMLHTTPnn classes if he needs to send extra header info. The usercontrol makes doing an async read easy/event based; whereas the XMLHTTPnn classes don't have events so you have to poll it's state if doing async. Thank you for your replies.
To clarify: The XML data comes in a data stream, instead of in a file. We need to access an XML data stream via a URL address. We want to capture the content of the stream to a string. Show quoteHide quote "Bill McCarthy" <TPASoft.com Are Identity Thieves> wrote in message news:%23R8QAjGmJHA.504@TK2MSFTNGP06.phx.gbl... > > "Jeff Johnson" <i.get@enough.spam> wrote in message > news:ua5MdBCmJHA.1172@TK2MSFTNGP04.phx.gbl... >> "Bill McCarthy" <TPASoft.com Are Identity Thieves> wrote in message >> news:OXUM0p7lJHA.4420@TK2MSFTNGP05.phx.gbl... >> >>> If you have the xml in a string you can use the DOMDocument's LoadXML >>> method. >> >> He doesn't have the XML. The question, as I understood it, was "How do I >> get XML from a Web request?" > > Ah, yep I think you're right. I think for that I'd favor using the > AsyncRead of a usercontrol class for simple urls, switching to the > XMLHTTPnn classes if he needs to send extra header info. The usercontrol > makes doing an async read easy/event based; whereas the XMLHTTPnn classes > don't have events so you have to poll it's state if doing async. > their answers are telling you ways to download the file.> To clarify: > The XML data comes in a data stream, instead of in a file. > We need to access an XML data stream via a URL address. We want to capture > the content of the stream to a string. > Once you've got it, it's easy enough to convert that to a string. The method that Bill McCarthy couldn't be bothered to explain usefully is detailed here: http://vb.mvps.org/samples/project.asp?id=netgrab For the XML method you might get better help in: microsoft.public.scripting.vbscript There are various XML object model libraries on Windows. The versions present vary. You can use those to download files. But the XML libraries are mainly high-level scripting tools. If you want to perform and control the download yourself, without needing external tools, see here for a sample that carries out the conversation with the server directly: www.jsware.net/jsware/vbcode.php5#htp And there are also Wininet functions for downloading, which basically wrap IE functionality. Of all of the above, Karl Peterson's "NetGrab" may be the easiest. Presumably you already know what you're doing once you get the XML string. If not, your choices are pretty much down to either simple parsing or using one of the XML libraries to translate the text into an XML object model. (As with HTML, you can either just parse it or load it into IE and deal with the document object.) For the XML object model, again, you might find more help in the vbscript group.
Stupid Format$ Question
OT: Win 3.1 optional args to a class.Init method Save Picture Q Should Reg-free COM still utilise an installation procedure? IE menu extension Office 2003 installer pops up when loading a project Gradient Windows Update KB960715 blocks MSFLXGRD.OCX!!!!! Any solution ? Reading Stack from VB6 |
|||||||||||||||||||||||