loadXML, parseXML -- What is Status? Workarounds?

loadXML doesn't generate errors but I am having trouble testing it. I notice that in August work was being done on the documentation for parseXML. Before I spend more time trying different strategies, I would like to know whether what's needed for xml parsing, close to what's available w/ processing javascript and processing, is implemented, or, what are good java libraries that work well with processing?

I am trying to do something similar to the P5 JS Weather Demo, except I need to work with xml files produced by the USGS. Some examples for working with XML would be great but ... then, ... I understand how that might not be possible.

I notice there are quite a few java libraries for working with xml files. A sample of the xml file I'm trying to work with is attached, I just need to use the data contained in the file, not write or stream. I've tried DOM getElements but it doesn't seem to work with loadXML generated DOM objects, only DOM page objects? I'm willing to try a third party library but I'd like to be working with one folks have found work well with P5 JS.

Answers

  • I don't understand why you talk about Java libraries about P5.js. Do you know a way to use Java libraries in a JavaScript environment?

  • I am probably not using the terms correctly. If I am not mistaken, this forum is for P5 JS. P5 JS is not processing javascript. Processing javascript files have a .pde extension and use libraries designed for processing javascript.

    Processing P5 JS files have a .js extension. P5 JS 'understands' java -- you can write your P5 JS sketch in java or parts of it in java -- and can integrate (to varying degrees, but mostly easy) with most of the millions and billions of java libraries available.

    I do not know how P5 JS relates to the next version of processing. It is my understanding that Processing 3 is more similar to P5 JS. I believe things are 'taking off' with P5 JS and it's not a dead end; that it may have a more pragmatic value in the years to come.

    See Processing Transition for an explanation of some differences between javascript and P5.js. As documentation develops, it will be easier to transition javascript sketches to P5 js so you can use java libraries (and code in java or learn to code in java).

    As a home hobbyist with no formal computer science training beyond Apple II basic in high school, I think you should treat all of the above with extreme uncertainty until statements herein are confirmed by persons more knowledgeable of Processing.

  • edited September 2014 Answer ✓

    P5.JS 'understands' Java -- you can write your P5.JS sketch in Java or parts of it in Java...

    That's where you're most wrong! What you describe above matches processing.js project, a.K.a JavaScript Mode!
    p5.js departs from Processing's Java main mode, in the same vein as Python, Ruby & CoffeeScript, etc. modes do!

    Only JavaScript Mode was made as a bridge between Java (offline) & JS (web) languages! O:-)
    Although Java can be run as a web applet, it's very awkward & problematic on doing that nowadays! [..]

    In short, even though p5.js & processing.js share JavaScript as their runtime language, their target lang differs! :-B

  • edited September 2014

    It's very confusing. I'm still learning how to integrate third party libraries ... is it more correct to say that P5 JS allows you to import any javascript libraries in addition to libraries built for P5 JS? (See Using a Library.)

  • edited September 2014 Answer ✓

    Gonna try make things clearer: Processing is a framework API for various programing languages.
    Processing includes many libraries accompanied by an IDE, so it's pretty easy to start writing our "sketches"!

    Now, p5.js is a new project that takes Processing to JavaScript. The same way that main Processing targets Java!
    It means that rather than writing code in Java as we do in Java & JS Modes , we'd use real JS for p5.js!

    However, every Processing project/mode shares a similar API library, already imported & ready-to-use!
    But if we wanna use other libraries, we gotta get 1 that corresponds to the Processing mode we're using.

    For Java Mode, it only accepts Java libraries. For both p5.js & processing.js (JS Mode) and even for CoffeeScript mode, it gotta be a JavaScript library instead! :D

  • edited September 2014 Answer ✓

    Another cause of confusion is about library types in relation to a framework! :-SS
    We can classify them in the following 3 major groups:

    1. Frameworks,
    2. Framework extensions,
    3. Regular "freelance" libs.

    Processing itself is a framework library:

    • Java mode uses 1 written in Java. Mainly known from its PApplet class.
    • Both JavaScript & CoffeeScript modes use the processing.js framework library.
    • And p5.js project uses the p5.js framework library. Yea, it's the same name! 3:-O

    Since a framework creates a whole environment w/ specific features & tools, we shouldn't mix them up.
    Once we choose a framework, it's extremely advisable not to import another 1 for the same app!

    Next, each framework can have other libraries which extend its built-in features.
    Those kinda libs only work for a specific framework though.

    And lastly, the normal libraries, which can be used in any framework. Or even w/o any framework! o=>

  • thanks for the in-depth explanation @GoToLoop!

Sign In or Register to comment.