is there anything exist to convert xml -> yaml directly?

十年热恋 提交于 2019-12-22 04:07:46

问题


is there any library or way exist from which I can convert my xml records to yaml format ?


回答1:


This page has a pretty long discussion of the problem. It suggests a couple of Python libraries that could be used: Gnosis and generateDS.




回答2:


The difference between XML and YAML is significant enough to warrant a redesign of the schema you are using to store your data. You should write a script to parse your XML records and output YAML formatted data.

There are some methods out there to convert any generic XML into YAML, but the results are far less usable than a method designed specifically for your schema.




回答3:


I think you want to look at the YAXML draft spec, which describes how to represent YAML data structures in XML.




回答4:


It's not clear whether you are looking for a way to do this inside a script/program, or any Python method will do.

In the latter case, the yq and xq utilities can do this:

cat file.xml | xq . | yq -y .

They might also be reusable as libraries or at least reused code.



来源:https://stackoverflow.com/questions/2943862/is-there-anything-exist-to-convert-xml-yaml-directly

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!