LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Match different words of a String and create an array/string with those words

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?

0 Kudos
Message 1 of 4
(544 Views)

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.

0 Kudos
Message 2 of 4
(522 Views)

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.

0 Kudos
Message 3 of 4
(510 Views)

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.

0 Kudos
Message 4 of 4
(502 Views)