Retrieving and processing a server side value from XML at runtime

mrs0572

New Member
I am trying to implement a solution to updating what a user control displays without republishing the user control itself. The UC gets xml from an external file as its content rather than storing the content in the control, so the xml is what is republished instead of the UC.The issue is that I also have a need for the content to contain inline variables such as <% =myvariable %>. Is there a way to retrieve the xml and then run that also at runtime instead of treating it as text?The following is just a rudimentary example with only the basics related to this issue specifically, not the full extent of the code on the page, but hopefully it is enough to illuminate what I am asking. Instead of just "Response.Write(xmlcontent);" is there some way I can get the value of the retrieve xml to run as if it were "native" to the page at runtime and process that inline variable?User Control:\[code\]<script runat="server">string xmlcontent = "";protected override void OnLoad(EventArgs e){ try { XmlDocument doc = new XmlDocument(); doc.Load(Server.MapPath("/usercontrols/xml/test.xml")); xmlcontent = doc.SelectSingleNode("content").InnerText; } catch { }}</script><%if (!string.IsNullOrEmpty(xmlcontent)) { Response.Write(xmlcontent); } %>\[/code\]XML:\[code\]<content><![CDATA[<div>This is the content. The next word is a C# variable <% =variabletest %>.</div>]]></content>\[/code\]
 
Back
Top