Forum: Ruby on Rails Parsing Filemaker 6 XML into something I can use

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Peter De Berdt (Guest)
on 2006-03-24 19:33
(Received via mailing list)
Hi

One of our customers has a Filemaker database which needs to be
accessed for some data. Using the Web Companion, I can query the
database for an XML version of the data. I need to be able to push
this data into an array of hashes, so I can access it in a more
convenient way. Filemaker is able to provide me with 2 XML formats
(DSO-XML and FMP-XML):

***********
DSO-XML
***********
<?xml version="1.0" encoding="UTF-8"?><FMPDSORESULT xmlns="http://
www.filemaker.com/fmpdsoresu
lt"><ERRORCODE>0</ERRORCODE><DATABASE>Customers.fp5</
DATABASE><LAYOUT>XMLDump</LAYOUT><ROW
MODID="0" RECORDID="13049791"><Company>Acme</
Company><Street>Somewherestreet 145
</Street><Postalcode>8200</Postalcode><City>Somecity</City></ROW><ROW
MODID="0" RECORDID="13049792"><Company>Acme the second</
Company><Street>Somewherestreet 146
</Street><Postalcode>8500</Postalcode><City>Somecity Elsewhere</
City></ROW></FMPDSORESULT>

***********
FMP-XML
***********
<?xml version="1.0" encoding="UTF-8"?><FMPXMLRESULT xmlns="http://
www.filemaker.com/fmpxmlresult"><ERRORCODE>0</ERRORCODE><PRODUCT
BUILD="9/10/2003" NAME="FileMaker Pro Web Companion" VERSION="6.0v2"/
 ><DATABASE DATEFORMAT="d-M-yyyy" LAYOUT="XMLDump"
NAME="Customers.fp5" RECORDS="26" TIMEFORMAT="k:mm:ss"/
 ><METADATA><FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="Company"
TYPE="TEXT"/><FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="Street"
TYPE="TEXT"/><FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="Postalcode"
TYPE="TEXT"/><FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="City"
TYPE="TEXT"/></METADATA><RESULTSET FOUND="26"><ROW MODID="0"
RECORDID="13049791"><COL><DATA>Acme</DATA></
COL><COL><DATA>Somewherestreet 145</DATA></COL><COL><DATA>8200</
DATA></COL><COL><DATA>Somecity</DATA></COL></ROW><ROW MODID="0"
RECORDID="13049792"><COL><DATA>Acme the second</DATA></
COL><COL><DATA>Somewherestreet 146</DATA></COL><COL><DATA>8500</
DATA></COL><COL><DATA>Somecity Elsewhere</DATA></COL></ROW></
RESULTSET></FMPXMLRESULT>

What would be the best way to get this into something I can use in my
controller? I've been playing around with REXML, but I'm hitting
walls here.

Thanks in advance!


Best regards

Peter De Berdt
Ben M. (Guest)
on 2006-03-25 09:10
(Received via mailing list)
What "walls" are you hitting? As long as Filemaker is giving you valid
xml, I would just
parse it with REXML and then grab what you need with XPaths.

http://www.germane-software.com/software/rexml/doc...

b
Peter De Berdt (Guest)
on 2006-03-25 10:02
(Received via mailing list)
On 25 Mar 2006, at 08:10, Ben M. wrote:

> What "walls" are you hitting? As long as Filemaker is giving you
> valid xml, I would just parse it with REXML and then grab what you
> need with XPaths.
>
> http://www.germane-software.com/software/rexml/doc...

That's exactly the kind of tutorial I was looking for. Thanks!

Best regards

Peter De Berdt
Michael N. (Guest)
on 2011-03-06 09:30
The Filemaker XML is something I find hard to use so I'll be trying to
export to Excel, then to CSV, then parse the CSV with either Ruby's
standard libraries or with fastercsv. If you export from Filemaker
directly to CSV, it doesn't give you the column headings, hence my
exporting to Excel format first. There's another gem called csv-mapper
which I have no experience with, but it's supposed to convert CSV to
active record - exactly what I need.
t.pickett66 (Guest)
on 2011-03-06 15:58
(Received via mailing list)
On Mar 6, 1:30am, Michael N. <removed_email_address@domain.invalid> wrote:
> The Filemaker XML is something I find hard to use so I'll be trying to
> export to Excel, then to CSV, then parse the CSV with either Ruby's
> standard libraries or with fastercsv. If you export from Filemaker
> directly to CSV, it doesn't give you the column headings, hence my
> exporting to Excel format first. There's another gem called csv-mapper
> which I have no experience with, but it's supposed to convert CSV to
> active record - exactly what I need.
>
> --
> Posted viahttp://www.ruby-forum.com/.

It sounds like you may already have a solution but don't want to RT*M.
That being said have you considered using something like Nokogiri
(http://nokogiri.org/) to parse the XML directly? I've had great
success parsing both HTML and XML using it, in fact it seems to be the
de facto parser used in the RoR community (someone correct me if I'm
wrong on this). But the point is, Nokogiri would probably save you a
couple steps and a lot of sanity if you intend to make going between
them (Filemaker and RoR) a regular thing.
This topic is locked and can not be replied to.