Xml ファイルのクエリを作成しようとしています。これは私の入力 Xml ファイルです:
<logentry
revision="10034">
<date>2009-10-07T03:45:38.000000Z</date>
<paths>
<path
kind="file"
action="M">/trunk/org.eclipse.mylyn.tasks/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepositoryConnectorTest.java</path>
<path
kind="file"
action="M">/trunk/org.eclipse.mylyn.tasks/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/core/BugzillaRepositoryConnectorStandaloneTest.java</path>
</paths>
</logentry>
2006 年 5 月 1 日から 2007 年 9 月 1 日までのすべてのログをフィルタリングしようとしています。私の出力は次のようになります。
10034 2009-10-07 BugzillaRepositoryConnectorTest.java、BugzillaRepositoryConnectorStandaloneTest.java
これは、date1 と date2 の間にある特定のリビジョン番号ごとに、 tag からのすべてのファイルのリストが必要であることを意味します。ファイル名とパスを分離するために正規表現を使用しました。
これは私のコードです:
using(System.IO.StreamWriter file1= new System.IO.StreamWriter( @"/home/datehistory"))
{XDocument log= XDocument.Load(@"/home/output.xml");
var selected= from logs in log.Descendants("logentry")
select new
{revno=logs.Attribute("revision").Value,
date=logs.Element("date").Value,
list1= {from files in logs.Element("paths").Element("path").Value
let match=Regex.Match(files,@"/([A-Za-z0-9\-]+.java)<",RegexOptions.IgnoreCase);
where match.Success
select new
{filename=match.Groups[1].Value }; }
???? "please help " where date between 2006-05-01 and 2007-09-01
};
foreach (var d in selected)
{
file1.Write(d.revno);
file1.Write("\t");
file1.Write(d.date);
file1.Write("\t");
foreach item in d.list1
{file1.write(item);
file1.write("\t"); }
file1.write("\n");
}