Extract text placed between HTML tags

douic -  
 douic -
Hello everyone,

I am currently a student on an internship and I am facing a problem that I don't know how to solve. I am looking to extract text from an HTML file that is placed inside two tags.

For example: "<name> blibla bli bla bla </name>", I want to retrieve the text "blibla bli bla bla"

Is this possible?
Can we retrieve each text from an HTML file placed between tags and put it into an Excel table?
What programming language should I use?
Is it possible in VBA (I have some knowledge)?

I am not looking for a ready-made solution but just some help, a code that could inspire me, a program that would do this or anything that could be useful for this task! Thank you for helping me as it will save me from long and tedious copying/pasting.

Thank you

4 answers

  1. Anonymous user
     
    Hello,

    Generally, the problem you are posing is treated in the reverse manner.

    We start from a CSV file or a database and create an HTML page with it.

    Are you sure you've approached the problem the right way?
    Because the purpose of the manipulation, unless you are looking for information on websites to process it afterwards.
    But in that case, you will be faced with the risk that the site you are reading changes, and your code will no longer work as a result.

    But to answer your question, it should be done in VBA, but you will need to work with the Windows APIs (inet.dll I believe) to access the website and retrieve the content.
    --
    Zébulon
    0
  2. douic
     
    Hello,

    I hadn't seen that you had replied... thank you! So yes, I'm sure it's in that direction. For more clarification, I want to retrieve the coordinates of the points placed in a KML (Google Earth) > I want to extract the text placed between the <coordinates> and </coordinates> tags.

    I've found some interesting links but they're in PHP and I'm not sure I'll manage. Is there anyone who can help me?

    Thanks everyone.
    0
    1. Anonymous user
       
      It's getting complicated.
      KML is a subclass of XML, so if you want to do it right, you should also use a proper XML parser, which also exists on Windows, so it should be doable.
      A few years ago, I did this kind of thing in VB6, almost like VBA actually, but now I'm on LINUX, so I can't really help you. Good luck.
      0
  3. Char Snipeur Posted messages 10112 Registration date   Status Contributor Last intervention   1 331
     
    A possible response here: https://www.w3schools.com/xml/xml_parser.asp
    Then, you look in your DOM to extract your coordinates. In this case, you just need to write a small script that you will run from your web browser (very simple).
    --
    The true submission is when the slaves worry about the price of cotton.
    Char Sniper
    0
  4. douic
     
    Ok, thank you, but you've lost me! I don't have the time to get into a script, etc., especially since I'm not sure I'll succeed in the end. In any case, thank you for your help.
    Best wishes.
    0