Open patricio1979 opened 3 years ago
If it is a valid XML file it should be able to load. Can you try passing the file to a XML validator (this one for example) and made sure there are no issues?
Hello Kenneth, I rethinking the problem.I'm using createInputFile for loading the musicXML files. Here's the editor.p5.js Web Editor
p5.js Web Editor
A web editor for p5.js, a JavaScript library with the goal of making coding accessible to artists, designers, ed... |
|
|
I attach the musicXML validated in the website that you gave me. Thank you for the quick response.Patricio
El miércoles, 16 de junio de 2021 18:49:55 GMT-5, Kenneth Lim ***@***.***> escribió:
If it is a valid XML file it should be able to load. Can you try passing the file to a XML validator (this one for example) and made sure there are no issues?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.
@scoresmexico Were you trying to attach a link to the web editor? It isn't show up here on GitHub, can you try again?
Oh sorry, the mail was sent from google.
https://editor.p5js.org/patricio1979/sketches/FGisDe1bb
I tried to upload the file but
The musicXML file has this structure and was validated on the website that you mentioned: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE score-partwise PUBLIC "-//Recordare//DTD MusicXML 3.1 Partwise//EN" "http://www.musicxml.org/dtds/partwise.dtd">
That didn't went well... https://pastebin.com/W691kaSE
You can enclose code blocks with three backticks (`) which will keep the tags in markdown.
loadXML()
accepts a URL string to load the XML data and does not accept XML strings directly. What you want would be something like the following
const parser = new DOMParser();
const xml = parser.parseFromString(xmlString, 'text/xml');
const xmlObject = new p5.XML(xml.documentElement);
It's not documented though but I think a new function for parsing XML strings could be helpful to add. In any case you can use the snippet above to get around your problem.
It still gives me an error. It builds a XML file with this info
<html>
<head></head>
<body xmlns="http://www.w3.org/1999/xhtml">
<parsererror style="display: block; white-space: pre; border: 2px solid #c77; padding: 0 1em 0 1em; margin: 1em; background-color: #fdd; color: black">…</parsererror>
</body>
</html>
Actually if you are using createFileInput()
you can skip a few steps and just do
function fileHandler(file){
const xmlObject = new p5.XML(file.data.DOM);
}
¡It works with files with XML extension! ...but no with musicXML file extension... Is there a way to correct this or is it the browser itself that throws error? El jueves, 17 de junio de 2021 11:36:02 GMT-5, Kenneth Lim @.***> escribió:
Actually if you are using createFileInput() you can skip a few steps and just do function fileHandler(file){ const xmlObject = new p5.XML(file.data.DOM); } — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.
So I guess the "Support for musicXML file" that i requested is still good?
El jueves, 17 de junio de 2021 11:36:02 GMT-5, Kenneth Lim ***@***.***> escribió:
Actually if you are using createFileInput() you can skip a few steps and just do function fileHandler(file){ const xmlObject = new p5.XML(file.data.DOM); } — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.
It's not specifically musicXML file that is the problem but rather a way to create p5.XML object. But I think in your case it isn't really that much of a step, just the data returned from createFileInput()
can be better documented.
Edit: if your musicXML file is valid XML it can be renamed with the .xml extension otherwise the browser won't recognized it as an XML file.
Hopefully there will be support for musicXML files and other types of XML.
Thanks for the help!
How would this new feature help increase access to p5.js?
Most appropriate sub-area of p5.js?
Feature enhancement details:
musicXML is an XML file, at least is structured like one. Can't seem to be able to open this file and be treated like a normal XML file.