471,093 Members | 2,009 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,093 software developers and data experts.

Accessing data from an Excel generated XML Spreadsheet

I wish to use XPath to access data from within an Excel generated XML Spreadsheet (generated with MS Excel 2003). I am using an asp Web page (not .NET, not at this time). I instantiate MSXML.DomDocument.3.0. After loading the Excel generated XML Spreadsheet parse error free, I issue the following XPath query to create a set of row nodes from within the document:
Expand|Select|Wrap|Line Numbers
  1. "//Workbook/Worksheet[@ss:Name='Upload Data']/Table/Row"
I am greeted with the following error: Reference to undeclared namespace prefix: 'ss'. When I examine the Workbook element of the document I see clearly defined the namespace for 'ss' as well as others. I have fiddled around with the Excel generated XML Spreadsheet and have occassionally gotten the XPath query to work. However, I would like to be able to use the Excel generated XML Spreadsheet document without changes. Are there any suggestions as to what I might do or what I am doing that is wrong? Below is some asp test code that I use for evaluation:

Expand|Select|Wrap|Line Numbers
  1.     dim sXPath, objXML: set objXML = server.CreateObject("MSXML2.DOMDocument.3.0")
  2.     dim objRoot, objNode, objNodeList, objRows, objDataColumns, objData, v
  3.     dim sPath: sPath = "C:\Sample_Dataset.xml"
  4.     if objXML.load(sPath) then
  5.         objXML.setProperty "SelectionLanguage", "XPath"
  6.         set objNodeList = objXML.selectNodes("//Workbook/Worksheet[@ss:Name='Upload Data']/Table/Row")
  7.         for each objRows in objNodeList
  8.             set objDataColumns = objNode.selectNodes("./Cell/Data")
  9.             for each objData in objDataColumn
  10.                 v = objData.text
  11.             next
  12.         next
  13.     end if
Dec 18 '06 #1
0 1638

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

9 posts views Thread by Ksenia Marasanova | last post: by
1 post views Thread by JV | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.