xmlだけの.trxファイル(単体テスト結果ファイル)があり、ファイルを読み取っていくつかのタグを比較し、必要に応じて変更して、ファイルを再度保存します。
VB.NETには役立つツールがいくつかあるので、最初に行うことは、ドキュメントをxmlドキュメントにロードすることです。これは正常に機能しているように見えますが、必要なデータにアクセスできません。現在、いくつかのテストを再実行した後、countersタグの属性にアクセスして変更しようとしています。
では、どうすればよいですか?
これによりファイルがロードされます。
Dim Doc As XmlDocument = New XmlDocument
Doc.load("testFile.trx")
ノードにアクセスする方法の試み:
Dim attribute As Integer = CInt(xmlTrxMasterDoc.SelectSingleNode("/TestRun/ResultSummary/Counters").Attributes(i).InnerText)
Dim node As XmlNode = xmlTrxMasterDoc.SelectSingleNode("/Counters")
Dim i As Integer = 1
node.Attributes.Item(i).InnerText
XML
<?xml version="1.0" encoding="utf-8"?>
<TestRun someattributes="" >
<ResultSummary outcome="Failed">
<Counters total="115" executed="115" passed="110" error="0" failed="5" timeout="0" aborted="0" inconclusive="0" passedButRunAborted="0" notRunnable="0" notExecuted="0" disconnected="0" warning="0" completed="0" inProgress="0" pending="0" />
</ResultSummary>
</TestRun>