Hi,
I need to to retrieve specific values from a HTML page. I've tried the jtidy solution and convert html to xml and then parse it from there but the HTML page contains errors and i;m not in the position to fix these errors. That leaves me with string functions or RegEx.
I've created a string function to work around it for now but I really want to understand RegEx better as I believe this can be handy in future usage as well. I've tried to go through the documentation but to be honoust I can't really get my head around it.
All tries on the https://b4x.com:51041/regex_ws/index.html page have failed and im only getting either single character values or nothing at all
I'm trying to get the Name, ID and Value.
I've created following string function to get the value based on the Name, this is working now but could easily break if website formatting changes and i'd like to understand regex better.
Note that I'm not taking the ID into account in below logic.
Can someone help me with generating the pattern for acquiring the name, id and value and explain each piece of the pattern so I can use it as learing curve?
call with:
I need to to retrieve specific values from a HTML page. I've tried the jtidy solution and convert html to xml and then parse it from there but the HTML page contains errors and i;m not in the position to fix these errors. That leaves me with string functions or RegEx.
I've created a string function to work around it for now but I really want to understand RegEx better as I believe this can be handy in future usage as well. I've tried to go through the documentation but to be honoust I can't really get my head around it.
All tries on the https://b4x.com:51041/regex_ws/index.html page have failed and im only getting either single character values or nothing at all
I'm trying to get the Name, ID and Value.
B4X:
<input type="hidden" name="ctl00$hdnUIDs" id="hdnUIDs" value="SAo7MZE2AeF92slcapwhmEqC2dTCiSTQKb9zgaHl6RzK01yVin0YVpchedG4L7Txt816xTaKLf2/CQ45Qk+1sQ==" />
<input type="hidden" name="ctl00$hdnSECs" id="hdnSECs" value="i/sXDoYis+NARUc6I9W61w==" />
<input type="hidden" name="ctl00$hdnNS" id="hdnNS" />
I've created following string function to get the value based on the Name, this is working now but could easily break if website formatting changes and i'd like to understand regex better.
Note that I'm not taking the ID into account in below logic.
Can someone help me with generating the pattern for acquiring the name, id and value and explain each piece of the pattern so I can use it as learing curve?
call with:
B4X:
GetElementValue(html,"ctl00$hs")
B4X:
Sub GetElementValue(s As String, name As String) As String
s= s.SubString2(s.IndexOf(name),s.Length)
s = s.SubString2(s.IndexOf("value="& QUOTE), s.IndexOf(QUOTE & " />"))
s= s.Replace("value=""E,"")
Return s
End Sub