0.4.24 change; getting "TypeError: x.getElementsByTagNameNS is not a function" error (worked on .23)

I have a sketch that works with 0.4.23, parsing some BPMN XML. Here is the relevant portion of the code:

`function preload() { ... x = loadXML("./assets/" + filename); ... }

function setup() { ... process = x.getElementsByTagNameNS("http://www.omg.org/spec/BPMN/20100524/MODEL", "process"); ... }`

When I run this same sketch with 0.4.24, I get this error in the console: TypeError: x.getElementsByTagNameNS is not a function pointing to the line listed above.

I had an XML parsing problem which I got working with the getElementsByTagNameNS call, above, as recommended. Worked great in 0.4.23.

Since it stopped working in 0.4.24, I was hoping someone could help me understand how the XML parser in P5 changed, so I can update my code to work again.

Thanks!

Answers

  • Check the result of accessing your namespace URL. I could be wrong but it looks like an unfortunate coincidence to me; and nothing to do with the change in p5 versions.

  • your response seems logical and, sure enough, it's a 404. Unfortunately, all the 2.0.2 specs on the OMG website - e.g. Semantic.xsd - point to the same namespace.

    And the fact that the very same (albeit invalid) URL works with 0.4.23 and doesn't work with 0.4.24 indicates that some behavior in p5js has changed...

  • And the fact that the very same (albeit invalid) URL works with 0.4.23 and doesn't work with 0.4.24 indicates that some behavior in p5js has changed...

    Ah - that's a very fair point ;)

    Looking at the history there have certainly been changes to the p5js XML code recently. Have you compared the output of loadXML between the two versions?

  • When I try it I get the following error in 0.4.24:

    p5.js:22764 Uncaught ReferenceError: parseXML is not defined

    My advice: file a bug report with p5js and don't use the bleeding edge ;)

  • edited April 2016

    OK - so the parseXML error happens in instance mode; but that's still a bug...

    In standard mode I see the same error as you; but the cause seems obvious enough. in 4.23 loadXML is returning a 'document' but in 4.24 it's giving you an Object. The document gives you access to the built-in getElementsByTagNameNS method; with the returned Object you're limited to the methods attached to it...

    Presumably the changes in p5 are intended to resolve issues similar to that which led you to use getElementsByTagNameNS; but they have the unfortunate side-effect of removing it as an available method.

  • All objects which are instances of class p5.Element got property elt which points to the actual HTMLElement. :-B

  • @GoToLoop - that's great; but this is dealing with the result of a loadXML call which should return an XML Object.

Sign In or Register to comment.