Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Having some fun with ASP and XML

Status
Not open for further replies.

bastienk

Programmer
Joined
Mar 3, 2004
Messages
326
Location
CA
I have the need to read the below XML file produced by a component that we use...
Code:
<Report xmlns="urn:schemas-microsoft-com:xml-data" xmlns:dt="urn:schemas-microsoft-com:datatypes" UserID="{0}" ID="{1F461501-4D6F-432D-BBD0-CACD541DD1B6}" Type="Call" Status="Completed">
	 <SubReport Recipient="2125551212" Status="Completed">
		 <Call xmlns="" Status="Failed">
			  <Time dt:dt="datetime">2004-04-29T09:35:25.000</Time> 
			  <Answer dt:dt="string">NoAnswer</Answer> 
			  <Protocol dt:dt="string" /> 
			  <Duration dt:dt="int">11</Duration> 
		 </Call>
		 <Call xmlns="" Status="Completed">
			  <Time dt:dt="datetime">2004-04-29T10:05:48.000</Time> 
			  <Answer dt:dt="string">Voice</Answer> 
			  <Protocol dt:dt="string" />1</Protocol>
			  <Duration dt:dt="int">30</Duration> 
		 </Call>
	 </SubReport>
 </Report>

As you can see the structure is very simple and not very deep. I am trying to write some ASP code that will open the file (no problem) and read across the node and attributes to retreive certain values. Here is the relevant code

Code:
Set objLst = objXML.getElementsByTagName("*")
  For i = 0 to objLst.length
    response.write "number of elements " & objLst.length& "<br>"
     If objLst.item(i).nodeName = "Call" Then
        response.write "here<br>"
        strCallStatus = objLst.item(i).attributes.getNamedItem("Status")
        response.write "SubReport status: " & strCallStatus & "<br>":response.flush
        if strCallStatus = "Completed" then
          CallTime     = objLst.firstChild.text
          CallAnswer   = objLst.nextSibling.text
          CallProtocol = objLst.nextSibling.text
          
          response.write CallTime & " " & CallAnswer & " " & CallProtocol & "<br>":response.flush
        end if
    else      
      Exit For
    End If
  Next

I keep getting errors (Object doesn't support this property or method on line 313 which is below the above code and not relevant as its a sql statement based on the above values...

If somone could give me a hint or two about getting this fixed, I'd greatly appreciate it....

TIA



Bastien

Cat, the other other white meat
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top