Public Sub SettingFile() Try Using xreder As XmlReader = _ XmlReader.Create(_filepath) While xreder.Read If xreder.ReadToFollowing("q") Then questions = xreder.ReadElementString anser = xreder.ReadElementString End If End While 'TODO リーダーを閉じる xreder.Close() End Using Catch ex As Exception MessageBox.Show(ex.Message.ToString()) End Try End Sub
<?xml version="1.0" encoding="Shift_JIS"?> <question> <contents no="1"> <q>Aさんの好きな食べ物は?</q> <anser>チョコ</anser> </contents> <contents no="2"> <q>Bさんの好きなスポーツは?</q> <anser>野球</anser> </contents> </question>