C# to MusicXML? [closed]

限于喜欢 提交于 2019-12-05 09:30:40

Since MusicXML has a XML schema available, you can use xsd.exe to create the classes that represent the XML structure:

xsd /c xlink.xsd musicxml.xsd container.xsd opus.xsd

Then you can use XmlSerializer to load and save the generated classes from/to files.

(For some reason, one of the schema files, osfpvg.xsd, wasn't able to compile correctly. Here's hoping you won't need it.)

To use xsd.exe, you can use this command:

"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools\xsd.exe" "c:\dev\musicxml30\musicxml.xsd" "c:\dev\musicxml30\xlink.xsd" "c:\dev\musicxml30\xml.xsd" /c /o:"c:\dev"

Which will create a file called musicxml_xlink_xml.cs in the c:\dev folder.

Compiled Class

For me when i tried to convert the MusicXml3.0.xsd, xsd.exe failed everytime. So, what i did was

xsd.exe musicFile.xml 

which generated a schema file, and

xsd.exe musicFile.xsd /classes

which produced the required c# classes. The only thing i had to add in order for the generated xml to be read by programs like Sibelius 7 was to add

<!DOCTYPE score-partwise PUBLIC "-//Recordare//DTD MusicXML 2.0 Partwise//EN" "http://www.musicxml.org/dtds/partwise.dtd">

And presto!

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