更改存储在变量中的动态HTML内容。 [英] Changing dynamic HTML content that is stored in a variable.

查看:98
本文介绍了更改存储在变量中的动态HTML内容。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,



我能够获取HTML内容并将其存储在名为Content的变量中。现在我想使用该变量更改HTML的内容,而不是在现有变量中进行更改,因为我无法访问该HTML文件。



以下是我的代码:



Dear All,

I am able to get the HTML content and store it in a variable called Content. Now I want to change the content of HTML using that variable rather than making changes in the existing variable as I have no access to that HTML file.

Below is my code :

<br />
<br />
Code behind: <br />
<br />
public string Content { get; set; }<br />
<br />
Matrix2CMSAPIWCFClient.MatrixCMSServiceSoapClient proxy = new Matrix2CMSAPIWCFClient.MatrixCMSServiceSoapClient();<br />
    			string jsonresp = proxy.GetWebsiteContent(<br />
    				Matrix2CMSAPIHelper.GenerateGetWebsiteContentRequest(<br />
    					username, password, DateTime.Now.ToString("yyMMddHHmmssff"), null,<br />
    					"cagecom/Customer-Service/FAQs"));<br />
    <br />
    			GetWebsiteContentResponse resp = Matrix2CMSAPIHelper.GenerateGetWebsiteContentReponse(jsonresp);<br />
    			if (resp.success)<br />
    			{<br />
    				Content = resp.content.contentHtml;<br />
        			}





HTML code:



HTML code:

<div class="grid_10 CustServContent">
        <%=Content %>
    </div>



正如您在后面的代码末尾所看到的,有一个名为Content的变量我在哪里阅读和存储HTML内容。请建议我如何修改HTML内容,例如在锚标记中指定链接,更改Div ID等,



问候


As you can see at the end of code behind, there is a variable called Content where I am reading and storing the HTML content. Please suggest me how do I modify HTML content like specifying a link in anchor tag, changing Div id, etc.,

Regards

推荐答案

现在Content是一个字符串,任何HTML元素都可以通过使用正则表达式来识别,因为HTML元素在该字符串变量中会有一定的模式。



示例:

Now that "Content" is a string and any HTML element can be identified by using regular expression as an HTML element would have a certain pattern in that string variable.

Example :
<br />
String Content = "<link type="text/css" rel="stylesheet" href="http://s.codeproject.com/App_Themes/CodeProject/Css/Main.min.css?dt=2.8.140216.1"><br />
<link type="text/css" rel="stylesheet" href="http://s.codeproject.com/App_Themes/CodeProject/CSS/jquery.autocomplete.min.css?dt=2.8.140216.1"><br />
"<br />





这里有一个链接,如上所述<然后是单词link,然后是一些字符串,后跟>。你需要编写正则表达式来提取这样的匹配并操纵它们。



如果有帮助,请告诉我。



A link here is havng a patten as mentioned "<" followed by word "link" then some string and follwed by ">". You need to write regex to extract such matching and manipulate them.

Let me know if that helps.


这篇关于更改存储在变量中的动态HTML内容。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆