Search code examples
htmlgame-maker

Using Game Maker Language, how do I isolate text in a specific HTML tag in a file into its own variable?


This may be a little different from most questions, because it deals with Game Maker Language.

What my program does:

Downloads an HTML page
Reads the page into a variable
Reads text in the first of a specific HTML tag

The last part is my problem. Under the first tag <h3><a HREF="dynamic content">TEXT HERE</a></h3> is the text I need to retrieve. Now, there are many of those lines in the document, I must get the first one. Also, one problem is that the HREF content does change every time this site is updated (Why I put 'dynamic content' there).

How do I process the variable to eliminate all text around the h3 tags, and how do I get the text data into its own variable without any clutter?

This is complicated in GML, I know. Much thanks to anyone who knows how to do this!


Solution

  • With the code function here, I have finally fixed my own problem. Hopefully this helps someone, sometime.

    //Variable to store original file data 
    working = argument0
    
    //Isolate string to h3 hyperlink 
    position = string_pos("<h3><a>",working) 
    working = string_delete(working,1,position) 
    
    //Delete all content after the version number 
    position = string_pos("</a></h3>",working) 
    working = string_delete(working,position, string_length(working) ) 
    
    return working