[R] XML Request in R: Pointers/examples needed
Lapointe, Pierre
Pierre.Lapointe at nbf.ca
Thu Jan 26 17:28:17 CET 2006
Hello R-helpers,
I'm new to XML. I have been using an application for some time, but now I
wish to automate my downloads with R. When I use the web interface of their
XML application, I'm able to read the response in R with the XML package.
My problem now is to send the requests directly from R. Here below are two
XML request scripts that come from the applicaton help file. My questions
are:
1- What type of scripts are those (first one is xml, but I'm
not sure about the second one)
2- How do I get them to work in R? I'm a loss with the first
one. As for the second one, I suspect I would have to use the rcom or
R(D)COM packages but I do not understand what I should do once I have
established the COM object.
(example: library(rcom)
comCreateObject("MSXML2.XMLHTTP.3.0")
Any pointers/examples would be appreciated.
#### Script #1 Logon Request#####################################
<?xml version="1.0"?>
<ds:Requests
xmlns:ds="http://product.datastream.com/zappy/dsxml_1_0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://product.datastream.com/zappy/dsxml_1_0
http://product.datastream.com/zappy/dsxml_1_0.xsd">
<ds:Request xsi:type="ds:SessionRequest">
<ds:UserName>myusername</ds:UserName>
<ds:Password>mypassword</ds:Password>
</ds:Request>
</ds:Requests>
#### Script #2 Request in HTTP Header############################
<script>
<!--
function Exec()
{
var objRequest = new ActiveXObject( "MSXML2.XMLHTTP.3.0" );
var request = "<?xml version="1.0"?>";
requests += <ds:Requests
xmlns:ds=\"http://product.datastream.com/zappy/dsxml_1_0\"
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
xsi:schemaLocation=\"http://product.datastream.com/zappy/dsxml_1_0
http://product.datastream.com/zappy/dsxml_1_0.xsd\">
<ds:Request xsi:type=\"ds:SessionRequest\">
<ds:UserName>myusername</ds:UserName>
<ds:Password>mypassword</ds:Password>
</ds:Request>
</ds:Requests>";
objRequest.open("POST","http://product.datastream.com/zappy/acces
spoint.asp, false);
objRequest.setRequestHeader ("DSXMLAPIREQUEST", request);
objRequest.send("");
//Get the response XML.
divResponse.innerText = objRequest.responseText
}
-->
</script>
#################################################################
Thank you
Pierre Lapointe
*****************************************
AVIS DE NON-RESPONSABILITE: Ce document transmis par courrie...{{dropped}}
More information about the R-help
mailing list