<%@ Import Namespace="System.Xml,System.IO" %> <script language="VB" runat="server"> Private Sub Page_Load(src As Object, e As EventArgs) Response.ContentType = "text/xml" Dim xmlwrt As XmlWriter = XmlWriter.Create(new StreamWriter(Response.OutputStream)) xmlwrt.WriteStartElement("doc") xmlwrt.WriteStartElement("elm") xmlwrt.WriteString("first element") xmlwrt.WriteEndElement() xmlwrt.WriteStartElement("elm") xmlwrt.WriteString("second element") xmlwrt.WriteEndElement() xmlwrt.WriteEndElement() xmlwrt.Close() End Sub </script>
Så ellers lovende ud, men den accepterer det ikke.
Compiler Error Message: BC30456: 'Create' is not a member of 'System.Xml.XmlWriter'.
Source Error:
Line 8: Line 9: Response.ContentType = "text/xml" Line 10: Dim xmlwrt As XmlWriter = XmlWriter.Create(new StreamWriter(Response.OutputStream)) Line 11: xmlwrt.WriteStartElement("doc") Line 12: xmlwrt.WriteStartElement("elm")
Imports System Imports System.IO Imports System.Xml Imports System.Web
NameSpace E Public Class OutXml Implements IHttpHandler Public Sub ProcessRequest(ctx As HttpContext) Implements IHttpHandler.ProcessRequest ctx.Response.ContentType = "text/xml" Dim xmlwrt As XmlWriter = XmlWriter.Create(new StreamWriter(ctx.Response.OutputStream)) xmlwrt.WriteStartElement("doc") xmlwrt.WriteStartElement("elm") xmlwrt.WriteString("first element") xmlwrt.WriteEndElement() xmlwrt.WriteStartElement("elm") xmlwrt.WriteString("second element") xmlwrt.WriteEndElement() xmlwrt.WriteEndElement() xmlwrt.Close() End Sub Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable Get Return True End Get End Property End Class End NameSpace
Ja sku da! :D - Kombination af dit første og sidste forslag gik igennem :) - Tusind tak! - du er sku for sej!
<%@ Import Namespace="System.Xml,System.IO" %> <script language="VB" runat="server"> Private Sub Page_Load(src As Object, e As EventArgs) Response.ContentType = "text/xml" Dim xmlwrt As XmlWriter = new XmlTextWriter(Response.OutputStream, Encoding.UTF8) xmlwrt.WriteStartElement("doc") xmlwrt.WriteStartElement("elm") xmlwrt.WriteString("first element") xmlwrt.WriteEndElement() xmlwrt.WriteStartElement("elm") xmlwrt.WriteString("second element") xmlwrt.WriteEndElement() xmlwrt.WriteEndElement() xmlwrt.Close() End Sub </script>
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.