从 SVG 文件到 XML 文件的转换
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27164637/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Conversion from SVG file to XML file
提问by Loganathan Sarangan
Can you explain how to convert SVG files to XML files?
您能解释一下如何将 SVG 文件转换为 XML 文件吗?
I am having design tool(EB guide) which generates SVG file format (contains state diagram). I need to use this SVG file in order to view the state diagram in Enterprise architect UML tool.
我有生成 SVG 文件格式(包含状态图)的设计工具(EB 指南)。我需要使用这个 SVG 文件才能在 Enterprise Architect UML 工具中查看状态图。
But, EA tool is not supporting SVG file. so i try to convert SVG file into xml file and then import in to EA tool.
但是,EA 工具不支持 SVG 文件。所以我尝试将 SVG 文件转换为 xml 文件,然后导入到 EA 工具中。
Is it possible to convert this SVG file format in to XML file format? is there any conversion tool available.
是否可以将此 SVG 文件格式转换为 XML 文件格式?有没有可用的转换工具。
logu
登录
回答by xmojmr
SVG file is alreadyin XML format. But it describes a picture. You can use a graphic programs to convert it to other picture formats, e.g. BMP, PNG which can be then inserted as an Imageelement into your diagram drawing canvas. (See also chapter "Using the Image Manager"in the help file)
SVG 文件已经是 XML 格式。但它描述了一张图片。您可以使用图形程序将其转换为其他图片格式,例如 BMP、PNG,然后可以将它们作为Image元素插入到您的绘图画布中。(另请参阅帮助文件中的“使用图像管理器”一章)
The XML file which can be imported into your EA model using the XMI Import and Exporttool must contain an UML model in the XMI format, not just a picture or a printscreen
可以使用XMI 导入和导出工具导入您的 EA 模型的 XML 文件必须包含XMI 格式的 UML 模型,而不仅仅是图片或打印屏幕。
回答by CoolMind
1) File > New > Vector Asset. Select SVG file in Path.
1)File > New > Vector Asset。选择 SVG 文件Path。
You will get a new XML file in drawablesfolder.
您将在drawables文件夹中获得一个新的 XML 文件。
Or you can use these methods.
或者您可以使用这些方法。
2) http://inloop.github.io/svg2android/
2) http://inloop.github.io/svg2android/
3) http://a-student.github.io/SvgToVectorDrawableConverter.Web/with checkbox "Specify --fix-fill-type".
3) http://a-student.github.io/SvgToVectorDrawableConverter.Web/勾选“指定 --fix-fill-type”。
回答by Prakazh Kumar
You can use Android Development Studio (Version >1.4):-
您可以使用 Android Development Studio(版本 >1.4):-
-Create a project
- 创建一个项目
-In any of the folder inside resource folder, right click and choose option 'New', in that choose 'Vector Asset'.
- 在资源文件夹内的任何文件夹中,右键单击并选择选项“新建”,然后选择“矢量资产”。
To use svg in android application it is required to be converted into xml.
要在 android 应用程序中使用 svg,需要将其转换为 xml。
Android will automatically convert your svg to xml, and you can get your xml file from resource folder.
Android 会自动将您的 svg 转换为 xml,您可以从资源文件夹中获取您的 xml 文件。
回答by Geert Bellekens
No that won't be possible. SVG is a graphics format, so it only contains information about imageof your diagram, not about the contents of the UML model it represents. It doesn't know about UML, so you'll never be able to use that as a format to import something into EA.
不,那是不可能的。SVG 是一种图形格式,因此它只包含有关图表图像的信息,而不包含它所代表的 UML 模型的内容。它不了解 UML,因此您永远无法将其用作将某些内容导入 EA 的格式。
What you need is an XMI file. XMI is the standard for UML models interchange. Check the documentation of your design tool to find out if there is an XMI export facility.
您需要的是一个 XMI 文件。XMI 是 UML 模型交换的标准。检查您的设计工具的文档以了解是否有 XMI 导出工具。
回答by mannjon
If anyone is still wondering about this...
如果还有人对此感到疑惑...
As long as the svg file is a true vector based svg file (meaning it contains no rasterized art) it is not just a graphics file, but retains the original paths associated with the vector object including colors, gradients, and other complex information.
只要 svg 文件是真正的基于矢量的 svg 文件(意味着它不包含光栅化艺术),它就不仅仅是一个图形文件,而且保留了与矢量对象相关联的原始路径,包括颜色、渐变和其他复杂信息。
If you can use path tools, I recommend a free open-source tool called Inkscape. It allows you to import a vector based svg file and export to xaml paths.
如果您可以使用路径工具,我推荐一个名为 Inkscape 的免费开源工具。它允许您导入基于矢量的 svg 文件并导出到 xaml 路径。
But this will only work if your diagram is in a true vector format.
但这只有在您的图表采用真正的矢量格式时才有效。
回答by Amit Gupta
If anyone still needs it.
如果还有人需要的话。
First, Scalable Vector Graphics (SVG) is an XML-based vector image format for two-dimensional graphics with support for interactivity and animation.
But, .svg and .xml are two different formats.So, .svg can be converted to .xml.
https://svg2vector.com/can be used to convert SVG to XML.
Also, Android Studio, Vector Asset can be used.
This may be helpful to convert SVG, PSD to XML
https://medium.com/@iamitgupta1994/converting-svg-psd-to-xml-vector-drawable-using-android-vector-asset-studio-8e8ec23d5405
首先,可缩放矢量图形 (SVG) 是一种基于 XML 的矢量图像格式,用于二维图形,支持交互性和动画。但是,.svg 和.xml 是两种不同的格式。因此,.svg 可以转换为.xml。
https://svg2vector.com/可用于将 SVG 转换为 XML。
此外,Android Studio、Vector Asset 也可以使用。这可能有助于将 SVG、PSD 转换为 XML
https://medium.com/@iamitgupta1994/converting-svg-psd-to-xml-vector-drawable-using-android-vector-asset-studio-8e8ec23d5405


