Hi -
I have a function that extracts XML data and stores it in a variable using local storage. (Thanks to @MarkHunte for that!).
Now I need to compare that extracted XML data to an external XML file that I have in my resource folder. Then, do something simple if the data does or does not match.
Is this possible and how would I do it?
I’ve attached an example file. In this example, I’m trying to compare the extracted data to NFExample.xml.
You should be able to read you local file probably as text and use DOMParser() to get it as an object.
Also you can do the same with the external score data.
if (typeof window.theScoreData == "undefined") {window.theScoreData= {} };
window.scoreView.getMusicXML().done(function(scoreData) {
window.theScoreData = scoreData
// do something with the returned score data
parser = new DOMParser();
xmlDoc = parser.parseFromString(scoreData, "application/xml");
console.log(xmlDoc)
});
I tried to set it up with a button function as you’v suggested but for some reason I’m getting an error: Uncaught (in promise) TypeError: Cannot read property ‘childNodes’ of undefined
When I just looked at your doc… I thought huh, that odd, he put a resu element/id to check the result the same as I did in my ( not posted )project file.
Then remembered I did that left that in the example code… doh.
Any way you did everything right and it works this end.
The problem will be that your noteflight is not fully loaded when you check.
You need to let it load fully first before you check. remember t you are asking the window.scoreView.getMusicXML() in there and that has to exist first.
The code is just an idea/example but you will need to work on when/how you safely do a check.
I would expect note flight to have some load complete api.
Hi Mark -
Thanks so much. I’m waiting forever and the score is loaded but I’m still not getting a result.
The Noteflight API for when the score is fully loaded is: scoreDataLoaded
I’m not exactly where to put that in your code. (I’m close but I don’t exactly understand what is happening yet!)
Thank you so much!
Matt
Thanks for this @MarkHunte .
So very strange!
I’m working at a location with VERY slow internet access. Could this be causing me a problem somehow?
(The score data including instrument-sound is loading completely though before I run the compare.)