ReportingAnalyst
MIS
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-comffice:spreadsheet"
xmlns="urn:schemas-microsoft-comfficeffice"
xmlns:x="urn:schemas-microsoft-comffice:excel"
xmlns:ss="urn:schemas-microsoft-comffice:spreadsheet"
xmlns:html=" <DocumentProperties xmlns="urn:schemas-microsoft-comfficeffice">
<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>
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-comffice:spreadsheet"
xmlns="urn:schemas-microsoft-comfficeffice"
xmlns:x="urn:schemas-microsoft-comffice:excel"
xmlns:ss="urn:schemas-microsoft-comffice:spreadsheet"
xmlns:html=" <DocumentProperties xmlns="urn:schemas-microsoft-comfficeffice">
<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>