Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 reading xml

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!
Before posting, make sure you have read this topic!

Screensize:
UserName:
Password:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkInsert EmailInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
   

T O P I C    R E V I E W
Jezmeister Posted - 08 October 2009 : 07:32:36
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:

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 Sub


Now, generally that works fine, however I'm now trying to read a feed with this content:

<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 :)

Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.41 seconds. Powered By: Snitz Forums 2000 Version 3.4.07