How do I write XML from a dataset to Response, including schema?

Discussion in 'ASP .Net' started by Alan Silver, Mar 17, 2005.

  1. Alan Silver

    Alan Silver Guest

    Hello,

    I am trying to write some XML from a DataSet out to the Response object,
    but I'm getting somewhat stuck.

    I started out with ...

    strXmlData = dstData.GetXml();
    Response.Write(strXmlData);

    which was fine, except it doesn't include the schema. I then discovered
    that I should have been using WriteXML instead of GetXML, as that allows
    me to tell it add the schema.

    This is where I got stuck. I can't work out what to use for the first
    parameter of WriteXML. The second one is the WriteSchema flag, but what
    do I use for the first?

    I tried ...

    dstData.WriteXml(Response, XmlWriteMode.WriteSchema);

    thinking that maybe Response was really a stream, but that didn't work.

    So, anyone know how to do this? I just want the most efficient way of
    sending the XML including schema to Response.

    TIA for any help

    --
    Alan Silver
    (anything added below this line is nothing to do with me)
    Alan Silver, Mar 17, 2005
    #1
    1. Advertising

  2. Alan Silver

    Brock Allen Guest

    Use Response.OutputStream :)

    -Brock
    DevelopMentor
    http://staff.develop.com/ballen



    > Hello,
    >
    > I am trying to write some XML from a DataSet out to the Response
    > object, but I'm getting somewhat stuck.
    >
    > I started out with ...
    >
    > strXmlData = dstData.GetXml();
    > Response.Write(strXmlData);
    > which was fine, except it doesn't include the schema. I then
    > discovered that I should have been using WriteXML instead of GetXML,
    > as that allows me to tell it add the schema.
    >
    > This is where I got stuck. I can't work out what to use for the first
    > parameter of WriteXML. The second one is the WriteSchema flag, but
    > what do I use for the first?
    >
    > I tried ...
    >
    > dstData.WriteXml(Response, XmlWriteMode.WriteSchema);
    >
    > thinking that maybe Response was really a stream, but that didn't
    > work.
    >
    > So, anyone know how to do this? I just want the most efficient way of
    > sending the XML including schema to Response.
    >
    > TIA for any help
    >
    Brock Allen, Mar 17, 2005
    #2
    1. Advertising

  3. Alan Silver

    Alan Silver Guest

    >Use Response.OutputStream :)

    Fantastic, thanks ;-)

    >-Brock
    >DevelopMentor
    >http://staff.develop.com/ballen
    >
    >
    >
    >> Hello,
    >> I am trying to write some XML from a DataSet out to the Response
    >> object, but I'm getting somewhat stuck.
    >> I started out with ...
    >> strXmlData = dstData.GetXml();
    >> Response.Write(strXmlData);
    >> which was fine, except it doesn't include the schema. I then
    >> discovered that I should have been using WriteXML instead of GetXML,
    >> as that allows me to tell it add the schema.
    >> This is where I got stuck. I can't work out what to use for the
    >>first
    >> parameter of WriteXML. The second one is the WriteSchema flag, but
    >> what do I use for the first?
    >> I tried ...
    >> dstData.WriteXml(Response, XmlWriteMode.WriteSchema);
    >> thinking that maybe Response was really a stream, but that didn't
    >> work.
    >> So, anyone know how to do this? I just want the most efficient way
    >>of
    >> sending the XML including schema to Response.
    >> TIA for any help
    >>

    >
    >
    >


    --
    Alan Silver
    (anything added below this line is nothing to do with me)
    Alan Silver, Mar 17, 2005
    #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.

Share This Page