473,657 Members | 2,376 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Reading in an XML Web-based page

I would like to be able to import the following xml document on a daily
basis to get the current exchange rates and then create the same output file
so
I can use Biztalk 2002 to import that file, but I am not sure how to do it?
Any ideas would be greatly appreciated.
http://www.bankofcanada.ca/stat/fx-xml.xml
Nov 12 '05 #1
1 2014
This will make a local copy of the XML data:

using System;
using System.Xml;

class Program {
static void Main(string[] args) {
XmlDocument doc = new XmlDocument();
doc.Load("http://www.bankofcanad a.ca/stat/fx-xml.xml");
doc.Save("c:\\t emp\\myrates.xm l");
}
}

If you also need to do a transform of some sort, you might want to use XSLT.
For example, the following XSLT program:

<?xml version="1.0" encoding="utf-8" ?>
<xsl:styleshe et xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
version="1.0"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
exclude-result-prefixes="xsi">
<xsl:template match="/">
<Currencies>
<xsl:apply-templates select="*"/>
</Currencies>
</xsl:template>
<xsl:template match="Observat ion_date">
<date><xsl:valu e-of select="."/></date>
</xsl:template>
<xsl:template match="Observat ion_data">
<rate><xsl:valu e-of select="."/></rate>
</xsl:template>
<xsl:template match="Observat ion">
<Currency>
<xsl:apply-templates select="*"/>
</Currency>
</xsl:template>
<xsl:template match="Currency _name">
<name><xsl:valu e-of select="."/></name>
</xsl:template>
</xsl:stylesheet>

converts the about XML into the following output format:

<Currencies>
<Currency>
<name>U.S. dollar</name>
<date>2005-08-04</date>
<rate>1.212</rate>
</Currency>
...

You can invoke this XSLT program from C# code as follows:

using System;
using System.Xml;
using System.Xml.Xsl;
using System.Text;

class Program {
static void Main(string[] args) {
XmlDocument doc = new XmlDocument();
doc.Load("http://www.bankofcanad a.ca/stat/fx-xml.xml");

XslTransform tran = new XslTransform();
tran.Load("tran sform.xsl");

XmlTextWriter output = new XmlTextWriter(" myrates.xml",
Encoding.UTF8);
output.Formatti ng = Formatting.Inde nted;
using (output) {
tran.Transform( doc, null, output);
}
}
}
There's a nifty XSLT debugger included with
http://lab.msdn.microsoft.com/vs2005/ that allows you to step right into the
above Transform() call so you can see what the XSLT program is doing. All
you have to do to enable debugging is replace "new XslTransform" with the
new XslCompiledTran sform(true) as follows:

XslCompiledTran sform tran = new XslCompiledTran sform(true);


"Miles Cousens II" <mc******@clear water.ca> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
I would like to be able to import the following xml document on a daily
basis to get the current exchange rates and then create the same output
file
so
I can use Biztalk 2002 to import that file, but I am not sure how to do
it?
Any ideas would be greatly appreciated.
http://www.bankofcanada.ca/stat/fx-xml.xml

Nov 12 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
1971
by: Abyss | last post by:
My view. anyone that doesn't like it tough, click off and stop reading it. I have spent the last 45 minutes reading through all the posts, and I believe that you have all missed the mark of that post. The post was not about strict or transitional pages, it wasn't even about
1
1273
by: Andrew Banks | last post by:
I've got the following code in a control and the reader doesn't seem to be working. The connection details are correct. Any ideas? I am reading data from this database to log the user and a lot of the details are the same. public class AdminNavigation : System.Web.UI.UserControl {
3
2451
by: TPS | last post by:
What is the best way to read values from the web.config file. I know how to read from the appSettings section, I want to read from other sections like those listed below. Thanks, TPS <customErrors mode="Off" defaultRedirect="/Pages/customerror.aspx"/> <authentication mode="Forms">
6
1097
by: Piz | last post by:
Hi all.... That's my question. I'm developing a web site in asp.net 2. This website will run in the intranet of my customers. Is there any way to block the reading of my aspx pages? In other words I want that my customer can execute aspx pages but he shouldn't open them for reading my code. Someone could help me?? :) many thanks
3
2072
by: Brad | last post by:
I'm working on a web app which will display LARGE tiff image files (e.g files 10-20+ mb). Files are hidden from users direct access. For other, smaller image files I have used FileStream to read in a file in a single Read and so my quesitons are: (1) What is a practical file size limit for reading using FileStream.Read (reading the file in a single read)...especially on a web server where I don't think I'd want to tax memory...
4
2259
by: Jonathan [sbrodolo] | last post by:
Hi there, I am using a LOTUS/DOMINO Web Service in my ASP.Net application and I am having quite a lot of problems. I have managed to solve most of them but this one it really is giving me terrible headaches. Web Service send's me back an XML that I have managed to read with an enormous quantity of problems (it sends me back an XML file with double XML declaration, not the real XML format). In case of server errors, DOMINO sends me back an...
2
3243
by: nnimod | last post by:
Hi. I'm having trouble reading some unicode files. Basically, I have to parse certain files. Some of those files are being input in Japanese, Chinese etc. The easiest way, I figured, to distinguish between plain ASCII files I receive and the Unicode ones would be to check if the first two bytes read 0xFFFE. But nothing I do seems to be able to do that. I tried reading it in binary mode and reading two characters in:
3
1579
by: Maxim Vexler | last post by:
Hello I'm looking for reading materials to educate myself on the security measures that should be taken to build a secure web site. What I'm referring to is web sites like the following : 1. http://www.securiteam.com/securityreviews/5DP0N1P76E.html 2. http://www.unixwiz.net/techtips/sql-injection.html 3. http://www.cgisecurity.com/articles/xss-faq.shtml
12
6362
by: Simon Hart | last post by:
Hi, I am using Impersonation and turned off anon access for my web service. I am using the administator to authenticate the request using ICredentials. I am simply trying to read a key in HKEY_CURRENT_USER from my Web Service method call which I am unable to. When I try and open it it returns null. Even iterating all keys under HKEY_CURRENT_USER only returns a handful of keys. I can happily read any key under HKEY_LOCAL_MACHINE. I have...
1
1644
by: ChrisFrohlich | last post by:
ASP.NET 2.0 with Text DataTypes: I've got a similar question going in the SQL group, but I was wondering if anyone has successfully implemented reading/writing character data from a Text datatype column in SQL 2000. I know there's a Varchar(MAX) feature in SQL2005, but my budget mocks me right now and I need to do it in SQL 2K. Situation: I'm building a resume DB, and for ease of input, I'd really like to be able to use a single...
0
8399
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8312
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8827
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
7337
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6169
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4159
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2732
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1622
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.