Re: How to write xml file using existing XML Schema file?

Discussion in 'ASP .Net' started by Martin Honnen, Nov 13, 2009.

  1. aspfun via DotNetMonster.com wrote:
    > My app used myDataset.xmlwrite to export dataset to xml file. It works fine
    > for data but first two lines need to modify as existing XML Schema file.
    > Below are the difference in first two lines:
    >
    > New xml file:
    >
    > <?xml version="1.0" standalone="yes" ?>
    > <NewDataSet>
    > <SpecSum>
    > <USER>ANDYK</USER>
    > <Grouper>Allergy/Immunology</Grouper>
    > <Auths>0</Auths>
    > <Cost>0</Cost>
    > </SpecSum>
    > <SpecSum>
    >
    > Old xml file:
    >
    > <?xml version="1.0" encoding="UTF-8" ?>
    > <dataroot xmlns:eek:d="urn:schemas-microsoft-com:eek:fficedata" generated="2009-11-
    > 12T09:19:20">
    > <SpecSum>
    > <USER>ANDYK</USER>
    > <Grouper>Allergy/Immunology</Grouper>
    > <Auths>0</Auths>
    > <Cost>0</Cost>
    > </SpecSum>
    > <SpecSum>
    >
    > How to change?
    >
    > from
    >
    > <?xml version="1.0" standalone="yes" ?>
    > <NewDataSet>
    >
    > to
    >
    > <?xml version="1.0" encoding="UTF-8" ?>
    > <dataroot xmlns:eek:d="urn:schemas-microsoft-com:eek:fficedata" generated="2009-11-
    > 12T09:19:20">
    >
    > (generated="2009-11-12T09:19:20" wil changed based on run time)
    >


    You could try to create an XmlDataDocument from your DataSet and then
    manipulate that XmlDataDocument and Save it e.g.
    XmlDataDocument doc = new XmlDataDocument(yourDataSetInstance);
    doc.DocumentElement.SetAttribute("generated",
    XmlConvert.ToString(DateTime.Now));
    would add that 'generated' attribute.

    --

    Martin Honnen --- MVP XML
    http://msmvps.com/blogs/martin_honnen/
    Martin Honnen, Nov 13, 2009
    #1
    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