|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Transform result into XmlDocument or XmlDataDocumentI'm relatively new to asp.net 2.0 and need some help on a very easy thing. I would like to store the result of the transformation in an object for further processing. But it seems that the Transform method can not do this. My code looks basically like the lines below. XmlDocument xmlDoc = new XmlDocument(); XmlDocument xmlOut = new XmlDocument(); XslCompiledTransform transform = new XslCompiledTransform(); xmlDoc.Load("myXMLFile.xml") transform.Load("MyXslFile.xsl"); transform.Transform(xmlDoc, (XsltArgumentList)null, xmlOut); There is obviously no overload for XmlDocument (or XmlDataDocument) as output. Do I really need to write the output to a file ??!! My final traget is to fill a tree with the xml result of the translation. Therefore I think, I need an XmlDocument object. Any hint is highly welcome Rolf as one of the overload returns an XmlReader I guess you can do the
following: xmlOut.Load (transform.Transform(xmlDoc, (XsltArgumentList)null, null)); /LM <Kemp***@ee.nec.de> wrote in message Show quote news:1148768478.794149.86350@y43g2000cwc.googlegroups.com... > Dear Experts, > > I'm relatively new to asp.net 2.0 and need some help on a very easy > thing. > I would like to store the result of the transformation in an object for > further processing. > But it seems that the Transform method can not do this. > My code looks basically like the lines below. > > XmlDocument xmlDoc = new XmlDocument(); > XmlDocument xmlOut = new XmlDocument(); > XslCompiledTransform transform = new XslCompiledTransform(); > > xmlDoc.Load("myXMLFile.xml") > > transform.Load("MyXslFile.xsl"); > > transform.Transform(xmlDoc, (XsltArgumentList)null, xmlOut); > > There is obviously no overload for XmlDocument (or XmlDataDocument) as > output. > Do I really need to write the output to a file ??!! > My final traget is to fill a tree with the xml result of the > translation. > Therefore I think, I need an XmlDocument object. > > Any hint is highly welcome > > Rolf > Dear Luc,
thank you for your quick feedback. I tried your idea, but unfortunately it does not work. I used both Load and LoadXml. Load , I think has no chance as it expects a string. LoadXml faild too. Meantime I found a hint to utilise the stream overload. So I assigned a MemoryStream object to the output. This seems to work, but now I have to get the stream content into the XmlDocument. Up to now I could not succedd to do this ( which is clearly my poor ability on .net 2.0) Any idea how ? Thanks Rolf > I tried your idea, but unfortunately it does not work. You have it reversed: LoadXml expect a string (Xml formatted) and Load > I used both Load and LoadXml. > Load , I think has no chance as it expects a string. > LoadXml faild too. expect either a file name or a stream. A stream (in this case an XmlReader) is one of the possible return value for Transform. What error do you get exactly. I have by now tried what I say and it works. The only difference with what I suggested previously is that you have to give a type to the third argument (to lift ambiguity when using null). i.e. use Target.Load (T.Transform (Source, null, (XmlUrlResolver) null)) ; Also I use V1.1, but I don't think it make a difference in this case. /LM |
|||||||||||||||||||||||