# musicXML importing

**URL:** <https://discourse.processing.org/t/musicxml-importing/30742>\
**Category:** Libraries\
**Created:** [June 16, 2021, 3:09pm UTC](https://discourse.processing.org/t/musicxml-importing/30742 "2021-06-16T15:09:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![patricio1979](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/patricio1979/32/13609_2.png) [@patricio1979](https://discourse.processing.org/u/patricio1979)\
**Post date:** [June 16, 2021, 3:09pm UTC](https://discourse.processing.org/t/musicxml-importing/30742/1 "2021-06-16T15:09:25Z")

</div>

Hello, I need to import a musicXML file into p5js por parsing

I found this post  
[https://forum.processing.org/two/discussion/22417/a-couple-of-processing-powered-music-vids](https://forum.processing.org/two/discussion/22417/a-couple-of-processing-powered-music-vids)

Do you have any hints for doing this?

---

<div class="post-metadata">

**Author:** ![micuat](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/micuat/32/19407_2.png) [@micuat](https://discourse.processing.org/u/micuat)\
**Post date:** [June 19, 2021, 8:31am UTC](https://discourse.processing.org/t/musicxml-importing/30742/2 "2021-06-19T08:31:43Z")

</div>

hi! have you tried this?

> **[jnetterf/musicxml-interfaces](https://github.com/jnetterf/musicxml-interfaces)**
>
> A parser and type definition set for MusicXML. Contribute to jnetterf/musicxml-interfaces development by creating an account on GitHub.

if you import with CDN

```auto
<script src="https://cdn.jsdelivr.net/npm/musicxml-interfaces@0.0.20/lib/index.min.js"></script>

```

the functions seem to be exposed to global (like p5.js).

---

<div class="post-metadata">

**Author:** ![patricio1979](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/patricio1979/32/13609_2.png) [@patricio1979](https://discourse.processing.org/u/patricio1979)\
**Post date:** [June 19, 2021, 1:56pm UTC](https://discourse.processing.org/t/musicxml-importing/30742/3 "2021-06-19T13:56:42Z")

</div>

Thank you, yes.  
Apparently there’s an issue when importing XML files into p5.js  
I’m getting all sorts of issues.

This worked with musicXML files

```auto
let img, button, stringy;

function setup() {
  img = createCanvas(300,300);
  button = createButton('2. show string');
  button.mousePressed(printy);
  button.position(0,35);
  
//https://riptutorial.com/javascript/example/7081/read-file-as-string?fbclid=IwAR15en-wov_STPVGY49g4m6QqALNhtaHDBYAiUYmpjbkgu-YTC3s28PLVYo
  document.getElementById('upload').addEventListener('change', readFileAsString)
}

function draw() {
  background(220);
}

function readFileAsString() {
    var files = this.files;
    var reader = new FileReader();
    reader.onload = function(event) {
        console.log('File content:', event.target.result);
      stringy = event.target.result;
    };
    reader.readAsText(files[0]);
}

function printy(){
  print(stringy);
}

```

For those of you that want to work with another type of XML files that doesn’t have the XML extension, this is a solution.

---

<div class="post-metadata">

**Author:** ![patricio1979](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/patricio1979/32/13609_2.png) [@patricio1979](https://discourse.processing.org/u/patricio1979)\
**Post date:** [July 1, 2021, 1:44pm UTC](https://discourse.processing.org/t/musicxml-importing/30742/4 "2021-07-01T13:44:49Z")

</div>

I got in touch with the people of OpenSheetMusicDisplay that unites Vexflow.js and musicXML  
Thank you!
