Jump to content

Importing an XML Data Source


Toby B

This topic is 6305 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Hello,

When I tried importing an XML file into Fm I got an "XML parsing error" stating that the element 'unit' is unknown. At line 631 and Column 10.

This is my first attempt at handling data supplied as XML. I have just enough knowledge to realise that I may need an XSLT file to 'prep' this source's data to be ready for importing into FM.

An example of the XML data that gets returned from a HTTP GET is shown below:

<?xml version="1.0" encoding="utf-8"?>

2007.01.08

AED

10

7.1756

per 10 currency units

2007.01.08

ZAR

10

3.6930

per 10 currency units

This data will provide me with Exchange Rates for around 180 currencies. Each 'item' element in the above XML represents one of these currency rates. I want to import each of these 'items' as a new record in a table of Currency Rates.

Does anyone know how I can write the XSLT to style this data ready for an FM Import.

I am not sure if this helps but the web service I am requesting this data from has also provided the following schema on their site, but not anything else in the way of documentation:

<?xml version="1.0" encoding="utf-8"?>

<?xml version="1.0" encoding="utf-16"?>

Thanks in advance on any help you may be able to give,

Toby

Link to comment
Share on other sites

  • 1 month later...

Comment,

Thanks for posting back an example XSLT. I am only just now getting back to trying to sort this part of the database out.

I am a little worried that depending on one source of currency rates might leave my database vunerable to any changes the third party XML source Website may make.

Therefore I want to add a backup XML source also. The source will be the European Central Bank which only provides 34 currency rates a day. I have been working with Christian Jäger's example database from FMI's website to work out how to import these rates also.

However the structure of this new XML is totally different. Being a newbie to XSLT I tried comparing your example XSLT with Christian's but it is not much good for learning as the two result in different structures. Christian's example is also a little old so I am not sure if the methods used have been superceeded in more recent revisions of FileMaker.

Your example breaks every currency rate down into its own record, with fields for date, rate and currency code.

Whereas Christian's makes records for each date and uses 34 fields (per record) for holding the individual rates.

I also presume that his XSLT is also written using the verbose method whereas yours is condensed.

I was wondering if you could take a look at his XSLT and adapt it to produce a record for each currency? I imagine you would have to pull the date value from the parent element for each record, but I am still trying to decypher the syntax of XSLT.

It would be a very useful learning tool to compare 2 XML sources, and their corresponding XSLTs with the same output as the result.

I would then be able work out how the syntax should be constructed for future needs.

Thanks for any help you can give,

Toby

Here is the example XML data:

----------------------------------------------

<?xml version="1.0" encoding="UTF-8"?>

Reference rates

European Central Bank

------------------------------------------------

And here is Christian's XSLT:

------------------------------------------------

<?xml version="1.0" encoding="UTF-8"?>

0

YES

1

NUMBER

0

..

------------------------------------------------

Link to comment
Share on other sites

Commment,

Disregard my last post.

I found your other reply to topic Topic#183816 which answered all my questions. Along with how to construct the XSL to pull in a parent element into a field.

Thank you very much for all your contributions to this site.

Toby

Link to comment
Share on other sites

This topic is 6305 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.