不懂你什么意思?如果要得到其中任何一个东东的值。用Xpath好了。非常方便。

解决方案 »

  1.   

    程序员要给自己点勇气咯    呵呵  using System.Xml ;
    .....XmlDocument doc=new XmlDocument();
    doc.Load("文件的名称(包括路径)");XmlNodeList mainTB=doc.GetElementsByTagName("book") ;//第一项book
    stirng  str = mainTB[0].ChildNodes[0].InnerXml; //<title>题目</title>
    str = mainTB[0].ChildNodes[1].InnerXml; //<author>作者</author>
    str = mainTB[0].ChildNodes[2].InnerXml; //<content>内容</content>
    .....
      

  2.   

    下面是QuickStart里面的一些代码,还有很多自己去看看。应该有收获。
    private const String localURL = "http://localhost/quickstart/howto/samples/Xml/QueryXmlDocumentXPath/cs/books.xml";public static void Main()
    {
        QueryXmlDocumentXPathSample myQueryXmlDocumentXPathSample = new QueryXmlDocumentXPathSample();
        myQueryXmlDocumentXPathSample.Run(localURL);
    }public void Run(String args)
    {
        Console.WriteLine("XPath Test started ...");    XPathDocument myXPathDocument = new XPathDocument(args);
        XPathNavigator myXPathNavigator = myXPathDocument.CreateNavigator();    // Get all the book prices
        XPathQuery(myXPathNavigator, "descendant::book/price");    // Get the ISBN of the last book
        XPathQuery(myXPathNavigator, "bookstore/book[3]/@ISBN");
    }private void XPathQuery(XPathNavigator myXPathNavigator, String xpathexpr )
    {
        try
        {
            Console.WriteLine("XPath query: " + xpathexpr);        // Create a node interator to select nodes and move through them (read-only)
            XPathNodeIterator myXPathNodeIterator =  myXPathNavigator.Select (xpathexpr);        while (myXPathNodeIterator.MoveNext())
            {
                Console.WriteLine("<" + myXPathNodeIterator.Current.Name + "> " + myXPathNodeIterator.Current.Value);
            }
            Console.WriteLine();
        }
        catch (Exception e)
        {
            Console.WriteLine ("Exception: {0}", e.ToString());
        }
    }
      

  3.   

    如果可以对XML文件做如下修改:
    <?xml version="1.0" encoding="utf-8" ?>
    <Root>
    <books>
    <book>
    <title>题目</title>
    <author>作者</author>
    <content>内容</content>
    </book>
    <book>
    ... ...
    </book>
    ... ...
    </books>
    </Root>
    可以使用DataSet.WriteXml() 将文件读入DataSet中,然后DataSet.Tables["books"]中用
    DataSet.Tables["books"].Row[0]["title"]和DataSet.Tables["books"].Row[0]["author"]
    作为条件过滤得到DataSet.Tables["books"].Row[0]["content"]
    个人意见,请你参考.