-2

C#でxmlファイルから読んでいます。属性と値を読み取ることはできますが、これに遭遇しました

<aims><![CDATA[Compare and contrast the structure, function and features of different cell types, including prokaryotic and eukaryotic cells, and plant and animal cells.
Describe evolutionary relationships between prokaryotic and eukaryotic cells.
Explain mitosis & meiosis & relationships between cell division & genetic variability.
Explain how plants use sunlight to generate energy in photosynthesis.
Describe relationships & interactions between cells in the tissues of plants & animals.
Apply appropriate scientific principles.
Analyse, present, evaluate and interpret scientific data from a wide variety of sources.]]></aims>

このノードには、読み取るべき多くの情報があります。(".") で終わる各文をこのような値として読みたい
1- 原核細胞と真核細胞、植物細胞と動物細胞など、さまざまな種類の細胞の構造、機能、および特徴を比較対照します。
2- 原核細胞と真核細胞の間の進化的関係を説明してください。等々

わかりました、このノード内でループしようとしています。この特定のノード内でループする方法はありますか?

4

3 に答える 3

2

おそらく、このテキスト全体がテキスト要素にあります。1 つの大きな文字列として取得したらvalue.Split(".")、文ごとに分割するために使用します。

于 2013-09-09T13:12:14.837 に答える
1
var sentences = XDocument.Load(fName)
                .Descendants("aims")
                .First().Value
                .Split(".".ToCharArray(),StringSplitOptions.RemoveEmptyEntries)
                .Select((line,i) => (i+1) + "- " + line.Trim())
                .ToList();
于 2013-09-09T13:44:34.050 に答える
0

以下を使用できます

String data= //Read from the required XML tag
String[] sentences=data.Split('.');
于 2013-09-09T13:15:52.980 に答える