Victor Charles
asked on
Help with creating xml file using VB.NET
Hi,
From button click event of my application, how do I create a new xml with the following data elements using VB.NET?
<?xml version="1.0" standalone="yes"?>
<DocumentElement>
<MyDataTable>
<LinkAID>0</LinkAID>
<ItemA></ItemA>
<ItemB></ItemB>
<ItemC></ItemC>
</MyDataTable>
</DocumentElement>
Thanks,
Victor
From button click event of my application, how do I create a new xml with the following data elements using VB.NET?
<?xml version="1.0" standalone="yes"?>
<DocumentElement>
<MyDataTable>
<LinkAID>0</LinkAID>
<ItemA></ItemA>
<ItemB></ItemB>
<ItemC></ItemC>
</MyDataTable>
</DocumentElement>
Thanks,
Victor
ASKER
Hi,
I need to build the XML string in a new file and save the file. The goal is to hard code the data elements from my button click event and have the following xml file in my application's folder.
Newfile.xml:
<?xml version="1.0" standalone="yes"?>
<DocumentElement>
<MyDataTable>
<LinkAID>0</LinkAID>
<ItemA></ItemA>
<ItemB></ItemB>
<ItemC></ItemC>
</MyDataTable>
</DocumentElement>
I need to build the XML string in a new file and save the file. The goal is to hard code the data elements from my button click event and have the following xml file in my application's folder.
Newfile.xml:
<?xml version="1.0" standalone="yes"?>
<DocumentElement>
<MyDataTable>
<LinkAID>0</LinkAID>
<ItemA></ItemA>
<ItemB></ItemB>
<ItemC></ItemC>
</MyDataTable>
</DocumentElement>
again, what EXACTLY is the problem?
ASKER
How do I write the code in VB.NET to create the XML file (Newfile.xml)?
some sample code:
and you call that function with the xml string as argument
Private Sub writeDebug(ByVal x As String)
Dim FILE_NAME As String ="C:\newfile.xml"
If System.IO.File.Exists(FILE_NAME) = False Then
System.IO.File.Create(FILE_NAME).Dispose()
End If
Dim objWriter As New System.IO.StreamWriter(FILE_NAME, True)
objWriter.WriteLine(x)
objWriter.Close()
End Sub
and you call that function with the xml string as argument
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank You.
* building the XML string
* saving the file
* fetching the data
please clarify