Question : append element xml using vb

my code is working fine, but I am not sure how to have my element have a open and closing, basically i want my vb to write the xml like so.


   
   
   
   
   
 


but this
I am not sure of the correct syntex.
and to close it at the end the elements.
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
Dim itemElement As XmlElement = document.CreateElement("item")
        Dim descElement As XmlElement = document.CreateElement("description")
        Dim compElement As XmlElement = document.CreateElement("company")
        '  Dim itemElement As XmlAttribute = document.CreateXmlDeclaration("item")
        Dim unitElement As XmlElement = document.CreateElement("unit_price")
        Dim caseElement As XmlElement = document.CreateElement("case_price")
        Dim SRPElement As XmlElement = document.CreateElement("SRP")
        'document.AppendChild("xml_text_writer")
        'document.DocumentElement.AppendChild(Now)
        ' document.DocumentElement.AppendChild(itemElement)
        'documentElement.firstChild.firstchild.nodeValue(+"\n")
        'objXMLWriter.WriteStartElement(String.Empty, "Provider", String.Empty)
        document.FirstChild.AppendChild(itemElement)
        document.DocumentElement.AppendChild(compElement)
        document.DocumentElement.AppendChild(descElement)
        document.DocumentElement.AppendChild(unitElement)
        document.DocumentElement.AppendChild(caseElement)
        document.DocumentElement.AppendChild(SRPElement)

Answer : append element xml using vb

Sorry, forgot about the attributes:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
        Dim itemElement As XmlElement = document.CreateElement("item")
 
        'append the attributes to itemElement
        itemElement.Attributes.Append(document.CreateAttribute("ID"))
        itemElement.Attributes.Append(document.CreateAttribute("case.size"))
        itemElement.Attributes.Append(document.CreateAttribute("pack.size"))
 
        Dim descElement As XmlElement = document.CreateElement("description")
        Dim compElement As XmlElement = document.CreateElement("company")
        Dim unitElement As XmlElement = document.CreateElement("unit_price")
        Dim caseElement As XmlElement = document.CreateElement("case_price")
        Dim SRPElement As XmlElement = document.CreateElement("SRP")
 
        'assuming you've already created a root node somewhere...
        document.FirstChild.AppendChild(itemElement)
 
        itemElement.AppendChild(compElement)
        itemElement.AppendChild(descElement)
        itemElement.AppendChild(unitElement)
        itemElement.AppendChild(caseElement)
        itemElement.AppendChild(SRPElement)
Random Solutions  
 
programming4us programming4us