The Forum has been Updated
The code has been upgraded to the latest .NET core version. Please check instructions in the Community Announcements about migrating your account.
I've been using the code below to read xml feeds for a while - iirc it's straight from the microsoft website anyway not my own work:
Now, generally that works fine, however I'm now trying to read a feed with this content:
I get a type mismatch when it gets to country id="12", and I have no way of changing that source file - I have tried using Replace to remove the offending ' id="12"' before it's used but with no luck - any ideas? I suppose keeping the id info would be a useful lesson but removing it would be a good enough fix.
thanks in advance :)
Code:
Dim adoRS 'ADODB.Recordset
Set adoRS = CreateObject("ADODB.Recordset")
' Set up the Connection
adoRS.ActiveConnection = "Provider=MSDAOSP; Data Source=MSXML2.DSOControl.2.6;"
' Open the XML source
adoRS.Open Server.MapPath(".") & "\portfolio.xml"
printtbl adoRS, 0
If adoRS.State = adStateOpen Then
adoRS.Close
End If
Set adoRS = Nothing
Response.End
' Function to recurcusively retrieve the data
Sub printtbl(rs, indent)
Dim rsChild 'ADODB.Recordset
Dim Col 'ADODB.Field
set rsChild = Server.CreateObject("ADODB.Recordset")
While rs.EOF <> True
For Each Col In rs.Fields
If Col.Name <> "$Text" Then ' $Text to be ignored
If Col.Type <> adChapter Then
' Output the non-chaptered column
Response.Write( String((indent)," " ) & Col.Name & ": " & Col.Value )
Else
Response.Write("<br/>")
' Retrieve the Child recordset
Set rsChild = Col.Value
rsChild.MoveFirst
If Err Then
Response.write("Error: " & Error )
Response.end
end if
printtbl rsChild, indent + 4
rsChild.Close
Set rsChild = Nothing
End If
End If
Next
Response.Write( "<br/>")
rs.MoveNext
Wend
End SubNow, generally that works fine, however I'm now trying to read a feed with this content:
Code:
<Track>
<Name>Lander Raceway</Name>
<Country id="12">Australia</Country>
<Laps>53</Laps>
<TotalParts>18</TotalParts>
<RaceStartTime>18</RaceStartTime>
<PitlaneLength>Medium</PitlaneLength>
<WearTyres>Big</WearTyres>
<WearFuel>Big</WearFuel>
</Track>I get a type mismatch when it gets to country id="12", and I have no way of changing that source file - I have tried using Replace to remove the offending ' id="12"' before it's used but with no luck - any ideas? I suppose keeping the id info would be a useful lesson but removing it would be a good enough fix.
thanks in advance :)
lblNoReplies