Link to home
Start Free TrialLog in
Avatar of Victor  Charles
Victor CharlesFlag for United States of America

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
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

as XML is, to start with, nothing else than "plain text/string", with though some "formatting" structure to be parseable, the question is where does your data come from, and what is your actual problem?

* building the XML string
* saving the file
* fetching the data

please clarify
Avatar of Victor  Charles

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>
again, what EXACTLY is the problem?
How do I write the code in VB.NET to create the XML file (Newfile.xml)?
some sample code:
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 

Open in new window


and you call that function with the xml string as argument
ASKER CERTIFIED SOLUTION
Avatar of SAMIR BHOGAYTA
SAMIR BHOGAYTA
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank You.