Is it possible to call DOM elements from HTML inside processing?

edited June 2015 in Library Questions

I have been wondering if it is possible to call DOM element by their ids or classes or tag. What I am trying to do is to get data from a website and open inside the processing.

for example I want to access the height/country table from the website into processing.

http://www.disabled-world.com/artman/publish/height-chart.shtml

Is there anyway we can do this?

Answers

  • The context of the question is a bit unclear, I first thought it was a question for Processing.js or P5.js...

    If what you want is to load an HTML page via loadStrings() (for example) and then find something in the markup, you should use a good HTML parsing library, like jsoup.

  • Oh thanks PhiLho, Sorry about the question but you guessed it right. I was trying to get the html element using ids or DOM element inside the processing. And yes I stumble upon this library "jsoup" and I was trying to use it with processing but I don't know how to convert java code into processing code. Can you please help me and illustrate a piece of code to show how to use jsoup with processing? I will work on your example and extent it for my use.

  • Basically, there is no need to convert any code, as Processing is Java itself. You need to make sure you've imported the library and Jsoup class should be available to you. The obvious rule is not to load anything in draw() as it would be executed many times, make your connection and extract elements in setup() instead.

Sign In or Register to comment.