12-28-2023 06:04 AM
Hello, I have a long string from a HTML where appears a model and each submodels (with a link). I want to extract a string with this info:
Alfa results.php?id=1 results.php?id=2 results.php?id=3 Alfa 2 results.php?id=4 results.php?id=5 results.php?id=6 ......................
The original string is bigger than the example, so I can't copy them by hand. I'm not sure if every word should be in an array or all in a single string.
Can anyone help me?
12-28-2023 07:48 AM
Hi,
You can try using the XML Parser API. See if you can adapt the code from my answer to this thread.
You can easily modify it to find the nodes named "ul", get their "id" attribute (which gives "Alfa" and "Alfa 2"), then get their sub-nodes "li", then sub-sub-nodes "a" with their attributes "href".
I would suggest to organize your data in an array of clusters, each representing a "panel" with its own list of "links".
If you encounter difficulties, attach your attempted modification of the code, I'll be happy to help.
Regards,
Raphaël.
12-28-2023 08:21 AM
Hello, I am using labview 2017. I have changed te html to a string and trying to use match regular expression. For the moment i haven't got sucess.
12-28-2023 08:37 AM - edited 12-28-2023 08:43 AM
Try this.
Your html string was ill-formatted, a closing </ul> was missing, which I added in the text file. Also, to be xml compliant, everything should be contained in a single parent node. So either programmatically add for example "<root>" at the beginning and "</root>" at the end of the string or directly extract one node higher from your full HTML document (where your HTML string originates). This allows to correctly parse the XML string.
If you want to do it without having the constraint of a correct XML syntax, I guess regular expressions could be a good alternative. However, this won't be easy because your data are organized in a hierarchical structure.