Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有几个以 xmi 格式保存的模型。我需要从 Rails 中的一些应用程序中读取它们。我不需要从 de xmi 文件构建模型,我只需要读取 xmi 文件具有的一些值。有任何想法吗?
提前致谢!
读取文件内容并在哈希中解析它:
fh=File.open("filename.xml", "r") data=Hash.from_xml(fh.read)
这只是一个例子。您所需要的只是将 xml 作为字符串,然后您可以使用 Hash.from_xml 对其进行解析并将其作为哈希处理。