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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XMLDOM and ASP

Status
Not open for further replies.
Oct 11, 2006
300
US
Hi,

I have an Excel file with one column of data. This excel file, I have saved it as an XML file. Now using the XMLDOM, I am trying to display the contents into a Textarea.

This is what I do in ASP code:


Code:
<%
Set objXML = Server.CreateObject("Microsoft.XMLDOM")
Set objLst = Server.CreateObject("Microsoft.XMLDOM")

objXML.async = False

objXML.Load (Server.MapPath("PresidentsClub.xml"))

If objXML.parseError.errorCode <> 0 Then
'handle the error
Response.Write (objXML.parseError.errorCode) & "<br>"
Response.Write (objXML.parseError.Property) & "<br>"
Response.Write (objXML.parseError.Property) & "<br>"
Response.Write "Unable to parse the XML File"
Else
Response.Write "XML Data Parsed"
End If

'a node list object containing all of the elements, or nodes, in the document
Set objLst = objXML.getElementsByTagName("*")

For i = 0 to (objLst.length - 1)

If objLst.item(i).nodeName = "Created" Then
StrDate = objLst.item(i).text
Exit For
End If

Next

Set objLst = objXML.getElementsByTagName("Cell")

strNoOfCells = objLst.Length

For i = 0 To (strNoOfCells - 1)

Set objHdl = objLst.item(i)
Response.Write(objHdl.childNodes(i).text)
Next
%>

I get the error:

Error Type:
Microsoft VBScript runtime (0x800A01A8)
Object required: 'objHdl.childNodes(...)'
/scripts/testing1/XML_Textarea.asp, line 46

Where line 47 refers to:


Code:
Response.Write(objHdl.childNodes(i).text)

Any ideas how I can resolve this error:

MY XML file looks like this:


Code:
<?xml version="1.0"?>
<?mso-application progid="Excel.Sheet"?>
<Workbook xmlns="urn:schemas-microsoft-com:eek:ffice:spreadsheet"
xmlns:eek:="urn:schemas-microsoft-com:eek:ffice:eek:ffice"
xmlns:x="urn:schemas-microsoft-com:eek:ffice:excel"
xmlns:ss="urn:schemas-microsoft-com:eek:ffice:spreadsheet"
xmlns:html=" <DocumentProperties xmlns="urn:schemas-microsoft-com:eek:ffice:eek:ffice">
<Author>ABC Communications</Author>
<LastAuthor>ABC Communications</LastAuthor>
<Created>2006-11-06T23:46:14Z</Created>
<Company>ABC Communications</Company>
<Version>11.8107</Version>
</DocumentProperties>
<Table ss:ExpandedColumnCount="1" ss:ExpandedRowCount="2" x:FullColumns="1"
x:FullRows="1">
<Row>
<Cell><Data ss:Type="String">john </Data></Cell>
</Row>
<Row>
<Cell><Data ss:Type="String">sally</Data></Cell>
</Row>
</Table>
 
>Response.Write(objHdl.childNodes(i).text)

For the source file structured as you've shown, it is this.
[tt] Response.Write(objHdl.childNodes([red]0[/red]).text)[/tt]
Or even this.
[tt] Response.Write(objHdl.text)[/tt]
 
This issue got resolved using :

Code:
<%
For i = 0 To (strNoOfCells - 1)
Set objHdl = objLst.item(i)
Response.Write (objlst.item(i).text) & vbcrlf
Next
%>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top