0
에 LINQ 기존 XML 파일에 요소를 추가, 그렇지 않은 경우, 하나 작성내 프로그램이 XML 파일이 이미 존재하는 경우 설정하기 위해 다음 코드를 실행 부하에 VB.NET
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If IO.File.Exists("Dictionary.xml") = False Then
Dim Dictionary As XDocument = <?xml version="1.0" encoding="utf-8"?>
<Root></Root>
MessageBox.Show("XML dictionary file created.")
End If
End Sub
그때 해요 각 단어에 대해이 xml 파일에 추가 할 4 개의 텍스트 상자에서 사용자 입력을 얻으려고합니다. 지금까지 해왔지만, 어떻게해야하는지에 대한 좋은 예를 찾을 수 없습니다.
Private Sub Save_Data_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Save_Data.Click
Dim Dictionary As XDocument = XDocument.Load("Dictionary.xml")
Dictionary.Add
<Word>
<English>Textbox1.Text</English>
<Transcription>Textbox2.Text</Transcription>
<Meaning>Textbox3.Text</Meaning>
<Sound>Textbox4.Text</Sound>
</Word>
End Sub