'// This is the pattern we want to match the hidden fields
Dim fieldSource As New Regex("(?<=""hidden"" name="").*?(?="")", _
RegexOptions.IgnoreCase Or RegexOptions.Singleline)
'// [Hidden Name Fields Count] This hold all the matches returned
Dim classMatches As MatchCollection = fieldSource.Matches(HTML)
'// Return the number of hidden fields
Dim numHiddenreFields As Integer = classMatches.Count
'// File location
Dim file As String = "Debug/xForm(4)-(file).xml"
'// The XmlTextWriter that will build the XML file
Dim myX As New Xml.XmlTextWriter(file, System.Text.Encoding.UTF8)
'// Add a few extra options to the XML
With myX
.Formatting = Formatting.Indented
.Indentation = 3
'// Write an element (this one is the root)
myX.WriteStartDocument()
myX.WriteStartElement("hiddenfileFields")
myX.WriteStartElement("hiddenfileChallenge")
myX.WriteStartElement("hiddenfileChallengeField")
myX.WriteValue(ChallengeField)
myX.WriteEndElement()
myX.WriteEndElement()
'// Use a for loop to go through tha array values
For Z As Integer = 0 To numHiddenreFields - 1
'1)
'// Set up the regular expression
Dim hiddenNames As New Regex("(?<=""hidden"" name="").*?(?="")", _
RegexOptions.IgnoreCase Or RegexOptions.Singleline)
'// This is an array of the files we don't want
Dim sourceNames As MatchCollection = hiddenNames.Matches(HTML)
' ''2)
' ''// Set up the regular expression
'Dim hiddenValues As New Regex("(?<=<input type=""hidden"" name=""" & sourceNames(Z).ToString & """ value="").*?(?="")", _
' RegexOptions.IgnoreCase Or RegexOptions.Singleline)
''// Put all the values in a collection
'Dim sourceValues As MatchCollection = hiddenValues.Matches(HTML)
'For Each sourceValues2 As Match In sourceValues
' MessageBox.Show(sourceValues2.ToString)
'Next
'// Write the values to the xml file
myX.WriteStartElement("reFields" & (Z))
myX.WriteValue(sourceNames(Z).ToString)
myX.WriteEndElement()
Next
'// Close up and end document
myX.WriteEndDocument()
myX.Close()
End With