| Author |
HELP--XMLHTTP newbie here.
|
|
| ibsimneej@hotmail.com 2005-02-21, 6:43 pm |
| Hi, I am a newbie to XMLHTTP. I am trying to load an XML from another
website using XMLHTTP and then filtered it via XMLDOM and then display
it in Xcel. I don't know of any other way of how to do it but any
help from anyone is welcome. Here is my code and it doesn't work.
code:
------------------------------------------------------
<script type = "text/vbscript"
set xmlhttp = CreateObject("Microsoft.XMLHTTP")
xmlhttp.open "Get", url , False
xmlhttp.send()
xmldoc = xmlhttp.responseText
Set xmldomdoc = CreateObject("Microsoft.XMLDOM")
xmldomdoc.load(xmldoc)
for each x in xmldomdoc.documentElement.childNodes
'Looking for for certain node tags here
if x.nodename = "uid" then
'Write the text here
document.write x.text
end if
next
-----------------------------------------------------------------
Here is an example of the XML URL file I'm trying to retrieve
<sdnEntry>
<uid>284</uid>
<lastName>AZRAK S.A.</lastName>
<sdnType>Entity</sdnType>
<programList>
<program>CUBA</program>
</programList>
<addressList>
<address>
<uid>185</uid>
<country>Panama</country>
</address>
</addressList>
</sdnEntry>
<sdnEntry>
<uid>306</uid>
<lastName>BANCO NACIONAL DE CUBA</lastName>
<sdnType>Entity</sdnType>
<programList>
<program>CUBA</program>
</programList>
<akaList>
<aka>
<uid>219</uid>
<type>a.k.a.</type>
<category>strong</category>
<lastName>BNC</lastName>
</aka>
<aka>
<uid>220</uid>
<type>a.k.a.</type>
<category>strong</category>
<lastName>NATIONAL BANK OF CUBA</lastName>
</aka>
</akaList>
<addressList>
<address>
<uid>199</uid>
<address1>Zweierstrasse 35</address1>
<city>CH-8022 Zurich</city>
<country>Switzerland</country>
</address>
</addressList>
</sdnEntry>
--------------------------------------------------------
| |
| Neil Smith [MVP Digital Media] 2005-02-21, 6:43 pm |
| You're not setting the url variable to a http address, it's
effectively set to nothing.
Cheers - Neil
On 21 Feb 2005 11:42:55 -0800, ibsimneej@hotmail.com wrote:
>Hi, I am a newbie to XMLHTTP. I am trying to load an XML from another
>website using XMLHTTP and then filtered it via XMLDOM and then display
>it in Xcel. I don't know of any other way of how to do it but any
>help from anyone is welcome. Here is my code and it doesn't work.
>
>code:
>------------------------------------------------------
><script type = "text/vbscript"
>set xmlhttp = CreateObject("Microsoft.XMLHTTP")
>xmlhttp.open "Get", url , False
>xmlhttp.send()
>xmldoc = xmlhttp.responseText
>Set xmldomdoc = CreateObject("Microsoft.XMLDOM")
>xmldomdoc.load(xmldoc)
>for each x in xmldomdoc.documentElement.childNodes
> 'Looking for for certain node tags here
> if x.nodename = "uid" then
> 'Write the text here
> document.write x.text
> end if
>
>next
>-----------------------------------------------------------------
>Here is an example of the XML URL file I'm trying to retrieve
><sdnEntry>
> <uid>284</uid>
> <lastName>AZRAK S.A.</lastName>
> <sdnType>Entity</sdnType>
> <programList>
> <program>CUBA</program>
> </programList>
> <addressList>
> <address>
> <uid>185</uid>
> <country>Panama</country>
> </address>
> </addressList>
> </sdnEntry>
> <sdnEntry>
> <uid>306</uid>
> <lastName>BANCO NACIONAL DE CUBA</lastName>
> <sdnType>Entity</sdnType>
> <programList>
> <program>CUBA</program>
> </programList>
> <akaList>
> <aka>
> <uid>219</uid>
> <type>a.k.a.</type>
> <category>strong</category>
> <lastName>BNC</lastName>
> </aka>
> <aka>
> <uid>220</uid>
> <type>a.k.a.</type>
> <category>strong</category>
> <lastName>NATIONAL BANK OF CUBA</lastName>
> </aka>
> </akaList>
> <addressList>
> <address>
> <uid>199</uid>
> <address1>Zweierstrasse 35</address1>
> <city>CH-8022 Zurich</city>
> <country>Switzerland</country>
> </address>
> </addressList>
> </sdnEntry>
>
>--------------------------------------------------------
| |
| ibsimneej@hotmail.com 2005-02-21, 6:43 pm |
| url should =
"http://www.ustreas.gov/offices/enforcement/ofac/sdn/sdn.xml"
I put in "url" because I didn't want to type this.
Sorry.
| |
| ibsimneej@hotmail.com 2005-02-21, 6:43 pm |
| I mistyped this: <script type = "text/vbscript"
and it should be <script type = "text/vbscript" >
with </script> at the end
| |
| Brian Staff 2005-02-21, 6:43 pm |
| Your XML structure is not valid. It needs to have a root node around the whole
structure.
The following line will fail:
xmldomdoc.load(xmldoc)
Suggestion:
xmldoc = "<xml>" & xmlhttp.responseText & "</xml>"
Brian
| |
| Neil Smith [MVP Digital Media] 2005-02-21, 6:43 pm |
| OK well we wasted some time there, then.
How about this : I generally use MSXML2.XMLHTTP as the object rather
than the older XMLHTTP. Secondly, I set the third parameter to "true".
This sets "async" connections, that is the connection waits till it's
established (blocks) before the script continues. If you set it to
false it's likely that the script will continue but have no XML loaded
(yet) or produce unpredictable results.
Also have a look at this very good tutorial which also shows cross
browser xmlhttp techniques - you can translate the javascript easily
to vbscript : http://jibbering.com/2002/4/httprequest.html
Cheers - Neil
On 21 Feb 2005 13:06:17 -0800, ibsimneej@hotmail.com wrote:
>url should =
>"http://www.ustreas.gov/offices/enforcement/ofac/sdn/sdn.xml"
>I put in "url" because I didn't want to type this.
>
>Sorry.
| |
|
| 1. You can't access resources in the domains other than your current
position. One workaround is use of server-side script.
2. If you want XML file, xmlhttp is not needed. Simply xmldom will do.
--
Pohwan Han. Seoul. Have a nice day.
<ibsimneej@hotmail.com> wrote in message
news:1109014975.752839.85400@c13g2000cwb.googlegroups.com...
> Hi, I am a newbie to XMLHTTP. I am trying to load an XML from another
> website using XMLHTTP and then filtered it via XMLDOM and then display
> it in Xcel. I don't know of any other way of how to do it but any
> help from anyone is welcome. Here is my code and it doesn't work.
>
> code:
> ------------------------------------------------------
> <script type = "text/vbscript"
> set xmlhttp = CreateObject("Microsoft.XMLHTTP")
> xmlhttp.open "Get", url , False
> xmlhttp.send()
> xmldoc = xmlhttp.responseText
> Set xmldomdoc = CreateObject("Microsoft.XMLDOM")
> xmldomdoc.load(xmldoc)
> for each x in xmldomdoc.documentElement.childNodes
> 'Looking for for certain node tags here
> if x.nodename = "uid" then
> 'Write the text here
> document.write x.text
> end if
>
> next
> -----------------------------------------------------------------
> Here is an example of the XML URL file I'm trying to retrieve
> <sdnEntry>
> <uid>284</uid>
> <lastName>AZRAK S.A.</lastName>
> <sdnType>Entity</sdnType>
> <programList>
> <program>CUBA</program>
> </programList>
> <addressList>
> <address>
> <uid>185</uid>
> <country>Panama</country>
> </address>
> </addressList>
> </sdnEntry>
> <sdnEntry>
> <uid>306</uid>
> <lastName>BANCO NACIONAL DE CUBA</lastName>
> <sdnType>Entity</sdnType>
> <programList>
> <program>CUBA</program>
> </programList>
> <akaList>
> <aka>
> <uid>219</uid>
> <type>a.k.a.</type>
> <category>strong</category>
> <lastName>BNC</lastName>
> </aka>
> <aka>
> <uid>220</uid>
> <type>a.k.a.</type>
> <category>strong</category>
> <lastName>NATIONAL BANK OF CUBA</lastName>
> </aka>
> </akaList>
> <addressList>
> <address>
> <uid>199</uid>
> <address1>Zweierstrasse 35</address1>
> <city>CH-8022 Zurich</city>
> <country>Switzerland</country>
> </address>
> </addressList>
> </sdnEntry>
>
> --------------------------------------------------------
>
| |
| ibsimneej@hotmail.com 2005-02-22, 6:42 pm |
| HI Han.
How? Any examples?
| |
|
| ibsimneej
Is the XML in the same domain as the caller?
Is the caller client-side script?
--
Pohwan Han. Seoul. Have a nice day.
<ibsimneej@hotmail.com> wrote in message
news:1109082623.934559.42730@c13g2000cwb.googlegroups.com...
> HI Han.
> How? Any examples?
>
| |
| ibsimneej@hotmail.com 2005-02-25, 6:37 pm |
| Basically, I'm reaching out to
"http://www.ustreas.gov/offices/enforcement/ofac/sdn/sdn.xml" to grab
the sdn.xml file and then I want to stream that onto my my pc and
filtered some of the data, should be client-server script.
This is a sample of the XML file that I want to extract info from the
<uid>, <LastName>, <Address>, and <Country> tag from this list and then
output it to an Excel spreadsheet.
Any ideas? Any info is much appreciated.
Ib
<sdnEntry>
<uid>284</uid>
<lastName>AZRAK S.A.</lastName>
<sdnType>Entity</sdnType>
<programList>
<program>CUBA</program>
</programList>
<addressList>
<address>
<uid>185</uid>
<country>Panama</country>
</address>
</addressList>
</sdnEntry>
|
|
|
|
| Copyright 2003 - 2008 forum4designers.com Software forum Computer Hardware reviews |