Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 SSIS and Import/Export (2005)
 Writing XML data from URL to Object in SS Script T

Author  Topic 

BIEngg
Starting Member

1 Post

Posted - 2010-09-20 : 12:16:54
I have this URL where there is XML data. I have to extract that data from URL and dump it into DW table. I am using SSIS Script Task for that.

This is how the data looks like:


<currency>
<csymbol>AED</csymbol>
<cname>United Arab Emirates Dirhams</cname>
<crate>3.6732001305</crate>
<cinverse>0.2722421770</cinverse>
</currency>
-<currency>
<csymbol>AFN</csymbol>
<cname>Afghanistan Afghanis</cname>
<crate>44.0000000000</crate>
<cinverse>0.0227272727</cinverse>
</currency>
-<currency>
<csymbol>ALL</csymbol>
<cname>Albania Leke</cname>
<crate>104.4100000001</crate>
<cinverse>0.0095776267</cinverse>
</currency>




This is the code i'm using to load it into some Object type or something. But i dont know how to do that.



public void Main()
{
String URLString = "http://Some URL";
XmlDocument doc = new XmlDocument();
XmlTextReader reader = new XmlTextReader(URLString);
doc.Load(reader);

XmlNodeList currencynodes = doc.SelectNodes("currency");
foreach(XmlNode currency in currencynodes)
{
XmlNode csymbol = currency.SelectSingleNode("csymbol");
string csymbolvalue = csymbol.Value;

XmlNode cname = currency.SelectSingleNode("cname");
string cnamevalue = cname.Value;

XmlNode crate = currency.SelectSingleNode("crate");
string cratevalue = crate.Value;

XmlNode cinverse = currency.SelectSingleNode("cinverse");
string cinversevalue = cinverse.Value;

Dts.Variables["User::oCurrencyConversion"].Value = csymbol.Value;
}
   

- Advertisement -