把xml文件做数据源,那么等价于sql的是XQuery,但是现在主要用XPath

解决方案 »

  1.   

    不能用sql,用xpath,找点资料看看。
      

  2.   

    no但是.net提供了很多操作xml的类,你可以看看那些System.Xml空间下的类。
      

  3.   

    DataSet.ReadXml();//读你的xml文件到一个DataSet
    然后DataTable.Select(),或者DataView.RowFilter =... //看看帮助,DataTable,DataView要么你就来硬的,直接在xml文件里找,见1楼说的。
      

  4.   

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnexxml/html/xml05192004.asp
    http://www.microsoft.com/china/MSDN/library/data/xml/Usxpthviewer.mspx
      

  5.   

    1、就是利用XPath来查询XML。2、用DataSet读去XML,然后在DataSet执行查询!!!
      

  6.   

    用sp_xml_preparedocument
    DECLARE @hDoc int
    EXEC sp_xml_preparedocument @hDoc OUTPUT, 
          N'<ROOT>
             <Customers CustomerID="XYZAA" ContactName="Joe" 
                   CompanyName="Company1">
                <Orders CustomerID="XYZAA" 
                   OrderDate="2000-08-25T00:00:00"/>
                <Orders CustomerID="XYZAA" 
                   OrderDate="2000-10-03T00:00:00"/>
             </Customers>
             <Customers CustomerID="XYZBB" ContactName="Steve"
                   CompanyName="Company2">No Orders yet!
             </Customers>
          </ROOT>'
    -- Use OPENXML to provide rowset consisting of customer data.
    INSERT Customers 
    SELECT * 
    FROM OPENXML(@hDoc, N'/ROOT/Customers') 
         WITH Customers
    -- Use OPENXML to provide rowset consisting of order data.
    INSERT Orders 
    SELECT * 
    FROM OPENXML(@hDoc, N'//Orders') 
         WITH Orders
    -- Using OPENXML in a SELECT statement.
    SELECT * FROM OPENXML(@hDoc, N'/ROOT/Customers/Orders') with (CustomerID nchar(5) '../@CustomerID', OrderDate datetime)
    -- Remove the internal representation of the XML document.
    EXEC sp_xml_removedocument @hDoc
      

  7.   

    加载到DataSet进行处理最方便。
      

  8.   

    导入DataSet后在过滤了like
    private void MakeDataView(DataSet ds)
    {
       DataView dv = new DataView(ds.Tables["Suppliers"], "Country = 'UK'", "CompanyName", DataViewRowState.CurrentRows);
       dv.AllowEdit = true;
       dv.AllowNew = true;
       dv.AllowDelete = true;
    }