简体   繁体   中英

Using XML as a datasource for Rails models

Is there a way to use external XML (or JSON) as a datasource for models in Rails. Eg some models use the database for getting data, others "ping" external services for XML.

您可以使用ActiveResource - 它已经是Rails的一部分,旨在允许您与外部的restful服务集成。

You could override the 'get' methods on the model, to look at your xml (or xml server) instead of looking at the database.
To parse xml on ruby, there are many apis, like rexml and xmlsimple .
Here there's a comparison between both.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM