Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > BOOK: XSLT Programmer's Reference, 2nd Edition
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: XSLT Programmer's Reference, 2nd Edition
This is the forum to discuss the Wrox book XSLT: Programmer's Reference, 2nd Edition by Michael Kay; ISBN: 9780764543814
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: XSLT Programmer's Reference, 2nd Edition section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 28th, 2006, 04:06 PM
Registered User
 
Join Date: Sep 2005
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default XPATH Help, Please- Excel XML Workbook

Sorry for the length... I need XPATH help.

I'm trying to extract some data from an Excel workbook saved as an XML spreadsheet.

Here's a very small sample file:

<?xml version="1.0"?>
<?mso-application progid="Excel.Sheet"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
 xmlns:o="urn:schemas-microsoft-com:office:office"
 xmlns:x="urn:schemas-microsoft-com:office:excel"
 xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
 xmlns:html="http://www.w3.org/TR/REC-html40">
 <DocumentProperties xmlns="urn:schemas-microsoft-com:office:office">
  <Author>us076006</Author>
  <LastAuthor>us076006</LastAuthor>
  <Created>2006-09-28T20:17:12Z</Created>
  <Company>3M</Company>
  <Version>11.8036</Version>
 </DocumentProperties>
 <ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">
  <WindowHeight>6405</WindowHeight>
  <WindowWidth>8475</WindowWidth>
  <WindowTopX>480</WindowTopX>
  <WindowTopY>90</WindowTopY>
  <ProtectStructure>False</ProtectStructure>
  <ProtectWindows>False</ProtectWindows>
 </ExcelWorkbook>
 <Styles>
  <Style ss:ID="Default" ss:Name="Normal">
   <Alignment ss:Vertical="Bottom"/>
   <Borders/>

   <Interior/>
   <NumberFormat/>
   <Protection/>
  </Style>
 </Styles>
 <Names>
  <NamedRange ss:Name="Low_Right" ss:RefersTo="=Sheet1!R2C2"/>
  <NamedRange ss:Name="Top_Left" ss:RefersTo="=Sheet1!R1C1"/>
 </Names>
 <Worksheet ss:Name="Sheet1">
  <Table ss:ExpandedColumnCount="2" ss:ExpandedRowCount="2" x:FullColumns="1"
   x:FullRows="1">
   <Row>
    <Cell><Data ss:Type="String">topLeft</Data><NamedCell ss:Name="Top_Left"/></Cell>
   </Row>
   <Row>
    <Cell ss:Index="2"><Data ss:Type="String">LowRight</Data><NamedCell
      ss:Name="Low_Right"/></Cell>
   </Row>
  </Table>
  <WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
   <Selected/>
   <Panes>
    <Pane>
     <Number>3</Number>
     <ActiveRow>1</ActiveRow>
     <ActiveCol>1</ActiveCol>
    </Pane>
   </Panes>
   <ProtectObjects>False</ProtectObjects>
   <ProtectScenarios>False</ProtectScenarios>
  </WorksheetOptions>
 </Worksheet>
</Workbook>


I'm looking for a way to capture all the Cell nodes that have data. I've tried "//Cell" in the select parameter in for-each, fully specifying the path, and a number of different templates matches, but can't nail it down. Specifically, I also want to capture Data element values based on the sibling "NamedCell" element.

It's possible that the parsing tool is not capable (MSXSL.exe)

Any help will be greatly appreciated!!!
  #2 (permalink)  
Old September 28th, 2006, 04:37 PM
mhkay's Avatar
Wrox Author
Points: 18,438, Level: 59
Points: 18,438, Level: 59 Points: 18,438, Level: 59 Points: 18,438, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,954
Thanks: 0
Thanked 290 Times in 285 Posts
Default

//Cell won't select anything, because the Cell elements are in namespace urn:schemas-microsoft-com:office:spreadsheet. You need to select them as //ss:Cell, with the prefix ss bound to "urn:schemas-microsoft-com:office:spreadsheet".

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
  #3 (permalink)  
Old September 28th, 2006, 08:47 PM
Registered User
 
Join Date: Sep 2005
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the fast answer Michael, Multiple namespaces are not something I've dealt with before. I'll give that a try...
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2003 workbook name qualifier AveryB Excel VBA 1 December 17th, 2007 10:41 PM
Unable to import from an Excel Workbook donevco Access 7 April 27th, 2007 09:37 AM
Import Excel data into a workbook Derek_05 Excel VBA 5 May 31st, 2006 02:02 PM
Closing Excel Workbook rekha_jsr Excel VBA 0 July 9th, 2005 02:40 AM
exporting a workbook from excel to access zisko3 Access 1 February 3rd, 2004 12:05 PM



All times are GMT -4. The time now is 02:45 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.