0

I'm using a script task to read an xml file and rewrite it to a new xml file using this code:

 DataSet data = new DataSet();
 data.ReadXml("C:\\xml.xml");
 data.Tables["Table"].WriteXml("C:\\newxml.xml");

It works fine now my question is how can i change that in such a way it reads from a variable and not a file? lets say my variable would be User::XmlData.

Thanks

anonymous1110
  • 885
  • 4
  • 14
  • 28

1 Answers1

0
        DataSet data = new DataSet();
        string myVar = Dts.Variables["XMLData"].Value.ToString();
        StringReader sr = new StringReader(myVar);
        data.ReadXml(sr);
        data.Tables["Table"].WriteXml("C:\\newxml.xml");
anonymous1110
  • 885
  • 4
  • 14
  • 28