472,789 Members | 1,298 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,789 software developers and data experts.

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 1983
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.bankofcanada.ca/stat/fx-xml.xml");
doc.Save("c:\\temp\\myrates.xml");
}
}

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:stylesheet 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="Observation_date">
<date><xsl:value-of select="."/></date>
</xsl:template>
<xsl:template match="Observation_data">
<rate><xsl:value-of select="."/></rate>
</xsl:template>
<xsl:template match="Observation">
<Currency>
<xsl:apply-templates select="*"/>
</Currency>
</xsl:template>
<xsl:template match="Currency_name">
<name><xsl:value-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.bankofcanada.ca/stat/fx-xml.xml");

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

XmlTextWriter output = new XmlTextWriter("myrates.xml",
Encoding.UTF8);
output.Formatting = Formatting.Indented;
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 XslCompiledTransform(true) as follows:

XslCompiledTransform tran = new XslCompiledTransform(true);


"Miles Cousens II" <mc******@clearwater.ca> wrote in message
news:%2****************@TK2MSFTNGP10.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
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...
1
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...
3
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...
6
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...
3
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...
4
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...
2
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...
3
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....
12
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...
1
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...
0
by: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.