<?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">
    <Created>2006-09-13T11:21:51Z</Created>
    <LastSaved>2010-05-12T03:31:09Z</LastSaved>
    <Version>12.00</Version>
  </DocumentProperties>
  <OfficeDocumentSettings xmlns="urn:schemas-microsoft-com:office:office">
    <RemovePersonalInformation />
  </OfficeDocumentSettings>
  <ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">
    <WindowHeight>11640</WindowHeight>
    <WindowWidth>19200</WindowWidth>
    <WindowTopX>0</WindowTopX>
    <WindowTopY>90</WindowTopY>
    <ProtectStructure>False</ProtectStructure>
    <ProtectWindows>False</ProtectWindows>
  </ExcelWorkbook>
  <Styles>
    <Style ss:ID="Default" ss:Name="Normal">
      <Alignment ss:Vertical="Center" />
      <Borders />
      <Font ss:FontName="宋体" x:CharSet="134" ss:Size="11" ss:Color="#000000" />
      <Interior />
      <NumberFormat />
      <Protection />
    </Style>
    <Style ss:ID="s62">
      <Borders>
        <Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="1" />
        <Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1" />
        <Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1" />
        <Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="1" />
      </Borders>
    </Style>
    <Style ss:ID="s65">
      <Borders>
        <Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="1" />
        <Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1" />
        <Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1" />
        <Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="1" />
      </Borders>
      <Font ss:FontName="宋体" x:CharSet="134" ss:Size="11" ss:Color="#000000" ss:Bold="1" />
      <Interior ss:Color="#D8D8D8" ss:Pattern="Solid" />
    </Style>
  </Styles>
  <Worksheet ss:Name="Sheet1">
    <Table ss:ExpandedColumnCount="4" ss:ExpandedRowCount="7" x:FullColumns="1" x:FullRows="1" ss:DefaultColumnWidth="54" ss:DefaultRowHeight="13.5">
      <Row ss:Index="4">
        <Cell ss:StyleID="s65">
          <Data ss:Type="String">jiu</Data>
        </Cell>
        <Cell ss:StyleID="s65">
          <Data ss:Type="String">name1</Data>
        </Cell>
        <Cell ss:StyleID="s65">
          <Data ss:Type="String">name2</Data>
        </Cell>
        <Cell ss:StyleID="s65">
          <Data ss:Type="String">name3</Data>
        </Cell>
      </Row>
      <Row>
        <Cell ss:StyleID="s62">
          <Data ss:Type="Number">1</Data>
        </Cell>
        <Cell ss:StyleID="s62">
          <Data ss:Type="Number">2</Data>
        </Cell>
        <Cell ss:StyleID="s62">
          <Data ss:Type="Number">3</Data>
        </Cell>
        <Cell ss:StyleID="s62">
          <Data ss:Type="String">aaa</Data>
        </Cell>
      </Row>
      <Row>
        <Cell ss:StyleID="s62">
          <Data ss:Type="Number">1</Data>
        </Cell>
        <Cell ss:StyleID="s62">
          <Data ss:Type="Number">2</Data>
        </Cell>
        <Cell ss:StyleID="s62">
          <Data ss:Type="Number">3</Data>
        </Cell>
        <Cell ss:StyleID="s62">
          <Data ss:Type="String">aaa</Data>
        </Cell>
      </Row>
      <Row>
        <Cell ss:StyleID="s62">
          <Data ss:Type="Number">1</Data>
        </Cell>
        <Cell ss:StyleID="s62">
          <Data ss:Type="Number">2</Data>
        </Cell>
        <Cell ss:StyleID="s62">
          <Data ss:Type="Number">3</Data>
        </Cell>
        <Cell ss:StyleID="s62">
          <Data ss:Type="String">aaa</Data>
        </Cell>
      </Row>
    </Table>
    <WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
      <PageSetup>
        <Header x:Margin="0.3" />
        <Footer x:Margin="0.3" />
        <PageMargins x:Bottom="0.75" x:Left="0.7" x:Right="0.7" x:Top="0.75" />
      </PageSetup>
      <Print>
        <ValidPrinterInfo />
        <PaperSizeIndex>9</PaperSizeIndex>
        <HorizontalResolution>200</HorizontalResolution>
        <VerticalResolution>200</VerticalResolution>
      </Print>
      <Selected />
      <Panes>
        <Pane>
          <Number>3</Number>
          <ActiveRow>15</ActiveRow>
          <ActiveCol>1</ActiveCol>
        </Pane>
      </Panes>
      <ProtectObjects>False</ProtectObjects>
      <ProtectScenarios>False</ProtectScenarios>
    </WorksheetOptions>
  </Worksheet>
  <Worksheet ss:Name="Sheet2">
    <Table ss:ExpandedColumnCount="1" ss:ExpandedRowCount="1" x:FullColumns="1" x:FullRows="1" ss:DefaultColumnWidth="54" ss:DefaultRowHeight="13.5">
    </Table>
    <WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
      <PageSetup>
        <Header x:Margin="0.3" />
        <Footer x:Margin="0.3" />
        <PageMargins x:Bottom="0.75" x:Left="0.7" x:Right="0.7" x:Top="0.75" />
      </PageSetup>
      <Print>
        <ValidPrinterInfo />
        <PaperSizeIndex>9</PaperSizeIndex>
        <HorizontalResolution>200</HorizontalResolution>
        <VerticalResolution>200</VerticalResolution>
      </Print>
      <ProtectObjects>False</ProtectObjects>
      <ProtectScenarios>False</ProtectScenarios>
    </WorksheetOptions>
  </Worksheet>
  <Worksheet ss:Name="Sheet3">
    <Table ss:ExpandedColumnCount="1" ss:ExpandedRowCount="1" x:FullColumns="1" x:FullRows="1" ss:DefaultColumnWidth="54" ss:DefaultRowHeight="13.5">
    </Table>
    <WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
      <PageSetup>
        <Header x:Margin="0.3" />
        <Footer x:Margin="0.3" />
        <PageMargins x:Bottom="0.75" x:Left="0.7" x:Right="0.7" x:Top="0.75" />
      </PageSetup>
      <Print>
        <ValidPrinterInfo />
        <PaperSizeIndex>9</PaperSizeIndex>
        <HorizontalResolution>200</HorizontalResolution>
        <VerticalResolution>200</VerticalResolution>
      </Print>
      <ProtectObjects>False</ProtectObjects>
      <ProtectScenarios>False</ProtectScenarios>
    </WorksheetOptions>
  </Worksheet>
</Workbook>
怎么这样的获取不了,第一个workSheet中的Table呢呢?
XmlNode xmlNode = dom.SelectSingleNode(string.Format("Workbook/Worksheet/Table"));这个为什么获取出来 xmlNode的值总是NULL呢,请各位指教一下,谢谢

解决方案 »

  1.   

    XmlNodeList xmlImg = xmldoc.GetElementsByTagName("Table");
        foreach (XmlNode node in xmlTitle)
          {
              string id = node.Attributes["id"].Value;
          }
      

  2.   


      ///获取appSettings节点值,非ConfigurationManager.AppSettings方法,确保返回为最新值
            /// </summary>
            /// <param name="_node">节点名称</param>
            /// <returns></returns>
            public static string GetXml(string _node)
            {
                string file = "~/appSettings.config";
                string node = "/appSettings/add[@key='" + _node + "']";
                return GetXml(file, node);
            }
            /// <summary>
            /// 获取xml值
            /// </summary>
            /// <param name="filexml">xml名称</param>
            /// <param name="node">节点名称</param>
            /// <returns></returns>
            public static string GetXml(string filexml, string node)
            {            
                XmlDocument xDoc = new XmlDocument();
                xDoc.Load(HttpContext.Current.Server.MapPath(filexml));
                XmlNode app = xDoc.SelectSingleNode(node);
                return app.Attributes["value"].Value;
            }
      

  3.   

    用xmlNode .Attributes["value"].Value;试试可以获取到值不!
      

  4.   

    XmlNode node = doc.GetElementsByTagName("Table")[0];
      

  5.   

    需要加名称空间啊
    http://msdn.microsoft.com/zh-cn/library/h0hw012b%28VS.90%29.aspx
      

  6.   


    XmlDocument dom = new XmlDocument();
    dom.Load(Server.MapPath("a.xml"));
    XmlNamespaceManager nm = new XmlNamespaceManager(dom.NameTable);
    nm.AddNamespace("ss", "urn:schemas-microsoft-com:office:spreadsheet");
    nm.AddNamespace("mxh", "urn:schemas-microsoft-com:office:spreadsheet");
    nm.AddNamespace("o", "urn:schemas-microsoft-com:office:office");
    XmlNode xmlNode = dom.SelectSingleNode(string.Format("/mxh:Workbook/ss:Worksheet/ss:Table"),nm);
    Response.Write(xmlNode.InnerXml);