title: Create XML Files
body: <p>I want to create XML files from scratch in Visual studio using VB.net</p>
  
  <p>I found online Example but I struggled to understand how to add in some cases attributes and other cases child element . plus my top element have other elements.I mean my format is mucher longer but it looks like the below example: </p>
  
  <pre><code>    -&lt;CompanyFile&gt;
        -&lt;Companybranch name="something"&gt;
           -&lt;Customer&gt;
              &lt;name&gt;&lt;/name&gt;
              &lt;age&gt;&lt;/age&gt;
              &lt;address&gt;
                 &lt;addreesLine &gt; &lt;/addreesLine&gt;
               &lt;address&gt;
              &lt;/Customer&gt;
          &lt;/Companybranch&gt;
         &lt;/CompanyFile&gt;
  </code></pre>
  
  <p>I found a link that has basic XML format. </p>
  
  <pre><code>    Imports System.Xml
  
        Public Class Form1
          Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
      Dim writer As New XmlTextWriter("product.xml", System.Text.Encoding.UTF8)
      writer.WriteStartDocument(True)
      writer.Formatting = Formatting.Indented
      writer.Indentation = 2
      writer.WriteStartElement("Table")
      createNode(1, "Product 1", "1000", writer)
      createNode(2, "Product 2", "2000", writer)
      createNode(3, "Product 3", "3000", writer)
      createNode(4, "Product 4", "4000", writer)
      writer.WriteEndElement()
      writer.WriteEndDocument()
      writer.Close()
  End Sub
  Private Sub createNode(ByVal pID As String, ByVal pName As String, ByVal pPrice As String, ByVal writer As XmlTextWriter)
      writer.WriteStartElement("Product")
      writer.WriteStartElement("Product_id")
      writer.WriteString(pID)
      writer.WriteEndElement()
      writer.WriteStartElement("Product_name")
      writer.WriteString(pName)
      writer.WriteEndElement()
      writer.WriteStartElement("Product_price")
      writer.WriteString(pPrice)
      writer.WriteEndElement()
      writer.WriteEndElement()
  End Sub
  </code></pre>
  
  <p>End Class</p>
  
  <p>How can I create what I want One Node has List of elements then the list of elements may or may not have children or attributes.?</p>
  
  <p>THANK YOU!</p>