try this code here, it writes the first part fine, it is a little cumbersome but you can see how vb works with xml, the xmlwriter may be a better solution for you but this should get you going.
Public Function customXmlDoc() As XmlDocument
Dim xdoc As New XmlDocument
Dim dec As XmlDeclaration = xdoc.CreateXmlDeclaration("1.0", "utf-8", "yes")
xdoc.AppendChild(dec)
Dim ns As New XmlNamespaceManager(xdoc.NameTable)
ns.AddNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance")
Dim rootElement As XmlElement = xdoc.CreateElement("rootElement")
xdoc.AppendChild(rootElement)
Dim firstChild As XmlElement = xdoc.CreateElement("object-type")
Dim rootAtt As XmlNode = xdoc.CreateNode(XmlNodeType.Attribute, "type", xdoc.GetNamespaceOfPrefix("xsi"))
rootAtt.Value = "APP_TR_ERROR"
firstChild.Attributes.Append(rootAtt)
rootElement.AppendChild(firstChild)
Dim objects As XmlElement = xdoc.CreateElement("bd-objects")
firstChild.AppendChild(objects)
Dim _object As XmlElement = xdoc.CreateElement("bd-object")
objects.AppendChild(_object)
Dim fields As XmlElement = xdoc.CreateElement("fields")
_object.AppendChild(fields)
Dim field As XmlElement = xdoc.CreateElement("field")
field.InnerText = "PVH"
Dim att As XmlNode = xdoc.CreateNode(XmlNodeType.Attribute, "field-id", xdoc.GetNamespaceOfPrefix("xsi"))
att.Value = "apptrIBuyerName"
field.Attributes.Append(att)
fields.AppendChild(field)
Dim field1 As XmlElement = xdoc.CreateElement("field")
field1.InnerText = "INTERNAL"
Dim att1 As XmlNode = xdoc.CreateNode(XmlNodeType.Attribute, "field-id", xdoc.GetNamespaceOfPrefix("xsi"))
att1.Value = "apptrTestCompanyName"
field1.Attributes.Append(att1)
fields.AppendChild(field1)
Dim field2 As XmlElement = xdoc.CreateElement("field")
field2.InnerText = "TR-0000000340"
Dim att2 As XmlNode = xdoc.CreateNode(XmlNodeType.Attribute, "field-id", xdoc.GetNamespaceOfPrefix("xsi"))
att2.Value = "apptrNo"
field2.Attributes.Append(att2)
fields.AppendChild(field2)
Dim field3 As XmlElement = xdoc.CreateElement("field")
field3.InnerText = "2014-03-11T10:11:23+00:00"
Dim att3 As XmlNode = xdoc.CreateNode(XmlNodeType.Attribute, "field-id", xdoc.GetNamespaceOfPrefix("xsi"))
att3.Value = "apptrErrorOccurDate"
field3.Attributes.Append(att3)
fields.AppendChild(field3)
Return xdoc
End Function
ok, I will post this as an improved solution below
Public Function customXmlDoc() As XmlDocument
Dim xdoc As New XmlDocument
Dim dec As XmlDeclaration = xdoc.CreateXmlDeclaration("1.0", "utf-8", "yes")
xdoc.AppendChild(dec)
Dim ns As New XmlNamespaceManager(xdoc.NameTable)
ns.AddNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance")
Dim rootElement As XmlElement = xdoc.CreateElement("object-type", ns.LookupNamespace(("xsi")))
Dim rootAtt As XmlNode = xdoc.CreateNode(XmlNodeType.Attribute, "type", xdoc.GetNamespaceOfPrefix("xsi"))
rootAtt.Value = "APP_TR_ERROR"
rootElement.Attributes.Append(rootAtt)
xdoc.AppendChild(rootElement)
Dim secondRoot As XmlElement = xdoc.CreateElement("bd-objects")
rootElement.AppendChild(secondRoot)
Dim firstRow As XmlElement = xdoc.CreateElement("bd-object")
secondRoot.AppendChild(firstRow)
Dim fields As XmlElement = xdoc.CreateElement("fields")
firstRow.AppendChild(fields)
Dim field As XmlElement = xdoc.CreateElement("field")
field.InnerText = "PVH"
Dim att As XmlNode = xdoc.CreateNode(XmlNodeType.Attribute, "field-id", xdoc.GetNamespaceOfPrefix("xsi"))
att.Value = "apptrIBuyerName"
field.Attributes.Append(att)
fields.AppendChild(field)
Dim field1 As XmlElement = xdoc.CreateElement("field")
field1.InnerText = "INTERNAL"
Dim att1 As XmlNode = xdoc.CreateNode(XmlNodeType.Attribute, "field-id", xdoc.GetNamespaceOfPrefix("xsi"))
att1.Value = "apptrTestCompanyName"
field1.Attributes.Append(att1)
fields.AppendChild(field1)
Dim field2 As XmlElement = xdoc.CreateElement("field")
field2.InnerText = "TR-0000000340"
Dim att2 As XmlNode = xdoc.CreateNode(XmlNodeType.Attribute, "field-id", xdoc.GetNamespaceOfPrefix("xsi"))
att2.Value = "apptrNo"
field2.Attributes.Append(att2)
fields.AppendChild(field2)
Dim field3 As XmlElement = xdoc.CreateElement("field")
field3.InnerText = "2014-03-11T10:11:23+00:00"
Dim att3 As XmlNode = xdoc.CreateNode(XmlNodeType.Attribute, "field-id", xdoc.GetNamespaceOfPrefix("xsi"))
att3.Value = "apptrErrorOccurDate"
field3.Attributes.Append(att3)
fields.AppendChild(field3)
Dim secondRow As XmlElement = xdoc.CreateElement("bd-subobjects")
secondRoot.AppendChild(secondRow)
Dim firstChildRow2 As XmlElement = xdoc.CreateElement("object-type")
secondRow.AppendChild(firstChildRow2)
Dim attType2 As XmlNode = xdoc.CreateNode(XmlNodeType.Attribute, "type", xdoc.GetNamespaceOfPrefix("xsi"))
firstChildRow2.Attributes.Append(attType2)
attType2.Value = "APP_TR_ERROR_DETAIL"
Dim attType3 As XmlNode = xdoc.CreateNode(XmlNodeType.Attribute, "parent-type", xdoc.GetNamespaceOfPrefix("xsi"))
firstChildRow2.Attributes.Append(attType3)
attType3.Value = "APP_TR_ERROR"
Dim secondRowFirstChild As XmlElement = xdoc.CreateElement("fields")
firstChildRow2.AppendChild(secondRowFirstChild)
Dim secondRowFirstChildFirstChild As XmlElement = xdoc.CreateElement("field")
secondRowFirstChildFirstChild.InnerText = "103"
secondRowFirstChild.AppendChild(secondRowFirstChildFirstChild)
Dim att21 As XmlNode = xdoc.CreateNode(XmlNodeType.Attribute, "field-id", xdoc.GetNamespaceOfPrefix("xsi"))
secondRowFirstChildFirstChild.Attributes.Append(att21)
att21.Value = "apptrErrorCode"
Dim secondRowFirstChildSecondChild As XmlElement = xdoc.CreateElement("field")
secondRowFirstChildSecondChild.InnerText = "MISSING_MANDATORY_FIELDS"
secondRowFirstChild.AppendChild(secondRowFirstChildSecondChild)
Dim att22 As XmlNode = xdoc.CreateNode(XmlNodeType.Attribute, "field-id", xdoc.GetNamespaceOfPrefix("xsi"))
secondRowFirstChildSecondChild.Attributes.Append(att22)
att22.Value = "apptrErrorCodeName"
Dim secondRowFirstChildThirdChild As XmlElement = xdoc.CreateElement("field")
secondRowFirstChildThirdChild.InnerText = "MISSING_MANDATORY_FIELDS"
secondRowFirstChild.AppendChild(secondRowFirstChildThirdChild)
Dim att23 As XmlNode = xdoc.CreateNode(XmlNodeType.Attribute, "field-id", xdoc.GetNamespaceOfPrefix("xsi"))
secondRowFirstChildThirdChild.Attributes.Append(att23)
att23.Value = "apptrErrorCodeName"
Return xdoc
End Function