Well-Formed XML from Event Handers?

Discussion in 'XML' started by pbd22, Mar 13, 2007.

  1. pbd22

    pbd22 Guest

    Hi.

    How do i output a well-formed XML document from inside an active event
    handler? I tried this in VB.NET (using a stringbuilder) and I kept
    getting a parser error. Has anybody run into this problem and what was
    the solution?

    I thank you.
    Peter
    pbd22, Mar 13, 2007
    #1
    1. Advertising

  2. pbd22 wrote:

    > How do i output a well-formed XML document from inside an active event
    > handler? I tried this in VB.NET (using a stringbuilder) and I kept
    > getting a parser error. Has anybody run into this problem and what was
    > the solution?


    What kind of "event handler" are you talking about? Is that the ASP.NET
    page model? What else does the page contain besides the code for the
    event handler?


    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
    Martin Honnen, Mar 13, 2007
    #2
    1. Advertising

  3. pbd22

    pbd22 Guest

    On Mar 13, 10:17 am, Martin Honnen <> wrote:
    > pbd22 wrote:
    > > How do i output a well-formed XML document from inside an active event
    > > handler? I tried this in VB.NET (using a stringbuilder) and I kept
    > > getting a parser error. Has anybody run into this problem and what was
    > > the solution?

    >
    > What kind of "event handler" are you talking about? Is that the ASP.NET
    > page model? What else does the page contain besides the code for the
    > event handler?
    >
    > --
    >
    > Martin Honnen
    > http://JavaScript.FAQTs.com/



    Thanks for your reply Martin.

    Its VB.NET/ASP.NET 2.0 and the event handler is a custom handler that
    gets fired every time a byte is sent to a remote server for FTP. The
    only
    other method on the page is a Page_Load event that handles the upload
    of the files. Below is the event handler. I currently get a parser
    error becuase
    it keeps recreating the XML every time the event handler fires and I
    cant
    figure out how to avoid this - I need to replace/update it, not append
    to it.


    Public Sub onIncrementCallback(ByVal sender As Object, ByVal e As
    IncrementEventArgs)

    Dim sbhtml As StringBuilder = New StringBuilder
    sbhtml.Append("<?xml version='1.0' encoding='ISO-8859-1'?
    >")

    sbhtml.Append("<uploads>")
    sbhtml.Append("<upload>")
    sbhtml.Append("<filename>")
    sbhtml.Append(e.FileName)
    sbhtml.Append("</filename>")
    sbhtml.Append("<bytessent>")
    sbhtml.Append(e.BytesSent)
    sbhtml.Append("</bytessent>")
    sbhtml.Append("<filesize>")
    sbhtml.Append(e.TotalBytesToSend)
    sbhtml.Append("</filesize>")
    sbhtml.Append("<percent>")
    sbhtml.Append(e.ProgressPercentage)
    sbhtml.Append("</percent>")
    sbhtml.Append("</upload>")
    sbhtml.Append("</uploads>")
    Context.Response.ContentType = "text/xml"
    Response.Write(sbhtml.ToString)
    End Sub

    Thanks for your help,
    Peter
    pbd22, Mar 13, 2007
    #3
  4. pbd22 wrote:

    > it keeps recreating the XML every time the event handler fires and I
    > cant
    > figure out how to avoid this - I need to replace/update it, not append
    > to it.


    Ask in an ASP.NET group or forum.



    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
    Martin Honnen, Mar 13, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Timo Nentwig

    parsing non-well-formed XML (SAX)

    Timo Nentwig, Jun 4, 2004, in forum: Java
    Replies:
    2
    Views:
    852
    Timo Nentwig
    Jun 4, 2004
  2. Paul Flew

    Well-formed XML question

    Paul Flew, Jun 30, 2003, in forum: XML
    Replies:
    3
    Views:
    994
    Micah Cowan
    Jul 5, 2003
  3. Rimu Atkinson

    how is this XML not well-formed???

    Rimu Atkinson, Jul 9, 2003, in forum: XML
    Replies:
    1
    Views:
    1,087
    Peter Flynn
    Jul 15, 2003
  4. Arpan
    Replies:
    2
    Views:
    440
    Arpan
    Aug 24, 2006
  5. Rich Fowler
    Replies:
    2
    Views:
    1,302
    Rich Fowler
    Jan 22, 2010
Loading...

Share This Page