No se mucho como se crea un xml, pero encontre este codigo y me funciona muy bien, pero cuando me pidieron almacenar el archivo xml en una carpeta, me da error.
Código:
<WebMethod()> _
Public Sub myThrow2()
'Contruye el Detail de los elementos del SOAP fault.
Dim doc As New System.Xml.XmlDocument()
Dim node As System.Xml.XmlNode = _
doc.CreateNode(XmlNodeType.Element, _
SoapException.DetailElementName.Name, _
SoapException.DetailElementName.Namespace)
Dim LogPath As String = Path() + "\" + NameFile().ToString().ToUpper()
'Construye las especificaciones details del SoapException.
'Agrega el primer hijo del elemento XML detail.
Dim details As System.Xml.XmlNode = doc.CreateNode(XmlNodeType.Element, "mySpecialInfo1", "http://tempuri.org/")
'Agrega un segundo hijo del elemento XML detail con un atributo.
Dim details2 As System.Xml.XmlNode = doc.CreateNode(XmlNodeType.Element, "mySpecialInfo2", "http://tempuri.org/")
Dim attr As XmlAttribute = doc.CreateAttribute("t", "attrName", "http://tempuri.org/")
attr.Value = "attrValue"
details2.Attributes.Append(attr)
'Agrega el primer hijo del elemento XML detail.
Dim details3 As System.Xml.XmlNode = doc.CreateNode(XmlNodeType.Element, "FaulType", "http://tempuri.org/")
details3.InnerXml = "Valor del detalle"
'Añade los dos elementos hijos del nodo detail.
node.AppendChild(details)
node.AppendChild(details2)
node.AppendChild(details3)
doc.Save(LogPath)
End Sub
Y al ejecutarlo devuelve lo siguiente:
"System.Xml.XmlException: Este documento XML no es valido, El documento no tiene un elemento raiz..
en System.Xml.XmlDocument.Save(String filename)"
¿Que error estoy cometiendo?
:(