none
Script Task - how to convert Com object to String (XML NodeList) RRS feed

  • Question

  • I am using Foreach loop node list enumerator I need to iterate through some nodes in my XML file and pass them to a TSQL Stored Proc...I am getting those nodes one by one in the variable upon execution, but the issue is the Variable is Object type and I am getting System.XML.XMLelement type result..I have a script task to sort of show the messagebox pop up. I am getting System.XML.XMLElement as the message...instead of the XML...


    I have to pass this to my stored procedure which accepts XML datatype as a Parameter..I think If I use Execute SQL task..I can only map SSIS Variable of type string to the TSQL Parameter..

    Any clue how do I convert the variable of object type (System.XML.XMLElement to string..in Script task )...or how do I handle this if my approach is not right ..

    -thnx
    Wednesday, July 16, 2008 1:58 PM

Answers

  • Posted in your other thread as well:

     

    Code Snippet

    Dim var As Variables

    Dts.VariableDispenser.LockOneForRead("YourNodeObject", var)

         Dim xmlNode As System.Xml.XmlNode = CType(var("YourNodeObject").Value, Xml.XmlNode)

         var.Unlock()

        

    Dim strValue As String = xmlNode.OuterXml

     

    Dts.VariableDispenser.LockOneForWrite("YourNodeString", var)

    var("YourNodeString").Value = strValue

    var.Unlock()

     

    Dts.TaskResult = Dts.Results.Success

     

     

     

    You'll need to add a reference to System.Xml.dll in Project..References.
    Wednesday, July 16, 2008 3:21 PM
    Moderator