XML Parsing Error: junk after document element

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

  1. pbd22

    pbd22 Guest

    Hi.

    I have an event handler in VB.NET that gets called several times.
    The output of the event handler is XML that is being called by
    an xmlhttp request from the client.

    I am using a stringbuilder to create the XML document by
    appending the various parts:

    sbhtml.Append("<Some XML Tag>")

    The problem is that the XML document gets recreated every
    time the event handler fires and I get the junk error after the
    first document's parent tag is closed:

    XML Parsing Error: junk after document element

    Location: http://localhost:5223/PresentationTier/set/set_progress.aspx
    Line Number 1, Column 191:<?xml version='1.0' encoding='ISO-8859-1'?
    ><uploads><upload><filename>SomeVideo.gvi</filename><bytessent>0</

    bytessent><filesize>12444894</filesize><percent>0</percent></upload></
    uploads><?xml version='1.0' encoding='ISO-8859-1'?> ...

    SO: How do I prevent this? How Do I "UPDATE" the XML document every
    time the event handler fires and not "APPPEND" a new document to the
    recently created one?

    Thanks.
    Peter
    pbd22, Mar 12, 2007
    #1
    1. Advertising

  2. > XML Parsing Error: junk after document element

    An XML document must have one, and only one, top level element. You
    can't append to it; you have to actually read the document in and
    process it properly, inserting the new structure in a place that makes
    sense syntactically.

    Or -- a sloppy workaround, but sometimes useful -- don't append to your
    top-level document, but to an External Parsed Entity which is referenced
    by your document. External entities *can* be document fragments and have
    multiple top-level elements, if they're referenced in an appropriate place.

    --
    () ASCII Ribbon Campaign | Joe Kesselman
    /\ Stamp out HTML e-mail! | System architexture and kinetic poetry
    Joe Kesselman, Mar 12, 2007
    #2
    1. Advertising

  3. pbd22

    pbd22 Guest

    On Mar 12, 4:54 pm, Joe Kesselman <> wrote:
    > > XML Parsing Error: junk after document element

    >
    > An XML document must have one, and only one, top level element. You
    > can't append to it; you have to actually read the document in and
    > process it properly, inserting the new structure in a place that makes
    > sense syntactically.
    >
    > Or -- a sloppy workaround, but sometimes useful -- don't append to your
    > top-level document, but to an External Parsed Entity which is referenced
    > by your document. External entities *can* be document fragments and have
    > multiple top-level elements, if they're referenced in an appropriate place.
    >
    > --
    > () ASCII Ribbon Campaign | Joe Kesselman
    > /\ Stamp out HTML e-mail! | System architexture and kinetic poetry



    Thanks for the response Joe.
    After rereading my post, I am realizing this isn't an XML issue.
    I understand that my document isn't well-formed, I guess I am
    trying to figure out how to prevent the event handler from recreating
    the XML and hence, causing the "junk" error. I think this is a
    VB.NET issue. I'll repost. Thanks...
    pbd22, Mar 13, 2007
    #3
    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. Tony Prichard
    Replies:
    0
    Views:
    715
    Tony Prichard
    Dec 12, 2003
  2. Dave19

    Junk after document element

    Dave19, Feb 8, 2006, in forum: XML
    Replies:
    0
    Views:
    2,808
    Dave19
    Feb 8, 2006
  3. pbd22
    Replies:
    17
    Views:
    60,421
    pbd22
    Sep 11, 2006
  4. Le
    Replies:
    0
    Views:
    1,031
  5. John Ramsden
    Replies:
    6
    Views:
    220
    John Ramsden
    Sep 12, 2003
Loading...

Share This Page