Emergent ESI
asked on
Creating and loading and Server.CreateObject("Microsoft.XMLDOM") in C#
Hello Everyone,
Can someone please help me figure out what is the equivalent C# code for the following:
set xmldoc = Server.CreateObject("Micro soft.XMLDO M")
xmldoc.load(Request)
I am trying to receive an xsl as dom object and I thought this might work
XslCompiledTransform xslDoc = (XslCompiledTransform)Serv er.CreateO bject("MSX ML2.DOMDoc ument.3.0" );
but I am not sure how to load the Request. I want to use this as part of an ASP.Net page.
Thanks.
Can someone please help me figure out what is the equivalent C# code for the following:
set xmldoc = Server.CreateObject("Micro
xmldoc.load(Request)
I am trying to receive an xsl as dom object and I thought this might work
XslCompiledTransform xslDoc = (XslCompiledTransform)Serv
but I am not sure how to load the Request. I want to use this as part of an ASP.Net page.
Thanks.
http://bytes.com/topic/xml/answers/620865-transform-xml-xsl-compact-framework-c
This may help you. This was from that site
A simpler solution to use the XML DOM object:
From Project/Add Reference/COM add a reference to Microsoft XML v4.0.
SXML2.DOMDocument40 doc = new DOMDocument40Class();
When using the doc object you will see listed all its methods:
doc.load, doc.loadXML, doc.transformNode
A simpler solution to use the XML DOM object:
From Project/Add Reference/COM add a reference to Microsoft XML v4.0.
SXML2.DOMDocument40 doc = new DOMDocument40Class();
When using the doc object you will see listed all its methods:
doc.load, doc.loadXML, doc.transformNode
How are you retrieving the transform, is it coming from disk or from a Http request? Either way, since its a .Net app you will want to avoid using COM objects. You can do everything you need with the built-on System.Xml namespace objects.
ASKER
carl_tawn: I am getting the xslt from an http request.
So I still need to load the Request Object. Can you guys help me with that part please.
xslDoc.Load(???)
How do I get the Request object?
Sorry for the newbie questions. Thanks again.
So I still need to load the Request Object. Can you guys help me with that part please.
xslDoc.Load(???)
How do I get the Request object?
Sorry for the newbie questions. Thanks again.
Well, as a very simplistic example, you want something along the lines of:
HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create("http://some.url.com/test.xsl");
HttpWebResponse res = (HttpWebResponse)req.GetResponse();
// load the response into an XmlReader
XmlTextReader reader = new XmlTextReader(res.GetResponseStream());
// prepare the compiled transform
XslCompiledTransform transform = new XslCompiledTransform();
transform.Load(reader);
ASKER
carl_tawn: Thank you so much. Just one more question. If a client is sending me the xsl via a DOM document, how would I receive the Dom Object. From you code, I gather that
the code makes the initial call to http://some.url.com/test.xsl and would accept the response with HttpWebResponse.
I need to wait for a client to connect to my site. When they connect, they will be sending me a xsl using DOM. I am trying to figure out how to accept the object. Thanks and I am sorry for the confusion.
Thanks again.
the code makes the initial call to http://some.url.com/test.xsl and would accept the response with HttpWebResponse.
I need to wait for a client to connect to my site. When they connect, they will be sending me a xsl using DOM. I am trying to figure out how to accept the object. Thanks and I am sorry for the confusion.
Thanks again.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks carl_tawn.
I will be testing this and will get back to you. I have another question.
If I do the following:
XmlTextReader reader = new XmlTextReader(Request.Inpu tStream);
Do I still need to create the
Server.CreateObject("MSXML 2.DOMDocum ent.3.0")
or do I need the following?
SXML2.DOMDocument40 doc = new DOMDocument40Class();
I think the XmlTextReader takes care of this but I wanted to check.
Also, Do you have any suggesting on how to test this locally? I will not be able to test this for real with the actual client until Monday.
Thanks again you are a life saver!.
I will be testing this and will get back to you. I have another question.
If I do the following:
XmlTextReader reader = new XmlTextReader(Request.Inpu
Do I still need to create the
Server.CreateObject("MSXML
or do I need the following?
SXML2.DOMDocument40 doc = new DOMDocument40Class();
I think the XmlTextReader takes care of this but I wanted to check.
Also, Do you have any suggesting on how to test this locally? I will not be able to test this for real with the actual client until Monday.
Thanks again you are a life saver!.
No you don't need to. MSXML is the old COM based Xml object model. The .Net framework provides its own set of objects for dealing with Xml (XmlTextReader is one of them). This should be the preferred method of dealing with XML in your .Net apps otherwise you create a dependency on an external library, which you generally want to avoid if you can.
ASKER
Carl_tawn:
Does this still apply if the client is not a .Net client? In other words, can I still just use XmlTextReader and not use Server.CreateObject("Micro soft.XMLDO M") .
Thanks again.
Does this still apply if the client is not a .Net client? In other words, can I still just use XmlTextReader and not use Server.CreateObject("Micro
Thanks again.
You should be able to. The client app should just be trying to send the raw xml rather than trying to actually send an xmldom object so all you will need to do is read that data.
ASKER
Thank you soo much!
It worked.
Thanks.
It worked.
Thanks.