Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

xmlstream into treeview or xmldatasource

Avatar of sonicysa
sonicysa asked on
2 Comments1 Solution645 ViewsLast Modified:
I have the following code and I can use a URL for the xmldatasource if I put the following code into a response.write mode and then put it on an external server. I want to know though how to pass the xml into the data property of the xmldatasource control.

  DataSet ds = new DataSet("Test");
        ds.Load(cmd.ExecuteReader(), LoadOption.OverwriteChanges, "Test");

        XslCompiledTransform xsltvar = new XslCompiledTransform();
        string xslFilePath = Request.MapPath("~/test.xsl", Request.ApplicationPath, false);

        StringReader sr = new StringReader(ds.GetXml());
        XmlDocument doc = new XmlDocument();
        XmlElement root = doc.DocumentElement;
        XPathNavigator xPath = root.CreateNavigator();

        //XmlTextWriter writer = new XmlTextWriter("books.html", null);
        MemoryStream mystream = new MemoryStream();
        XmlTextWriter writer = new XmlTextWriter(mystream, null);

        //StreamWriter mystreamWriter = new StreamWriter(mystream);

        //Response.ContentType = "text/xml";
        xsltvar.Transform(xPath, null, writer);
        XmlTextReader reader = new XmlTextReader(mystream);
        //StreamReader mystreamReader = new StreamReader(mystream);
//here there must be a way to do it but I don't understand all the different stream manipulations really.
XmlDataSource1.Data = reader.ToString();
        XmlDataSource1.DataFile = null;
        XmlDataSource1.TransformFile = null;
        //TreeView1.DataSource = mystream;
Avatar of kodiakbear

Our community of experts have been thoroughly vetted for their expertise and industry experience.

This problem has been solved!
Unlock 1 Answer and 2 Comments.
See Answers