IronJS icon indicating copy to clipboard operation
IronJS copied to clipboard

can IronJS handle Xml via parameters?

Open jchonc opened this issue 12 years ago • 0 comments

If I pass an XmlDocument or XmlNode from C#, how can I get the results back? Here is the code:

        var ctx = new IronJS.Hosting.CSharp.Context();
        string js = @"
            var cn = x.InnerText;
            cn = ( cn == 'bbb' ) ? 'ccc' : ( cn + 'x' );
            x.InnerText = cn;
            cn
        ";
        XmlDocument doc = new XmlDocument();
        doc.LoadXml("<a>bbb</a>");
        ctx.SetGlobal("x", doc.DocumentElement);
        object o = ctx.Execute(js);
        XmlNode n = ctx.GetGlobalAs<XmlNode>("x");

here o = "ccc" but n.InnerText is still "bbb"..

jchonc avatar Mar 14 '13 15:03 jchonc