如何只获得asp.net c#中的第一个标签内容? [英] how to get only the first tag contents in asp.net c#?

查看:68
本文介绍了如何只获得asp.net c#中的第一个标签内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hi sir,
   I am getting the string like below, i need to get only the first <p> </p> tag contents. Kindly give me the solution for this problem.



Input:
********

<p>You should step up and use some of this amazing energy to take action -- the world needs what you've got! It's a really good day for some parties, startups and other fun things that just need some initiative.</p><p>More horoscopes! Check your , , , , , ...</p><p>Today's Free Sample Reading: </p><p></p>



Output:
**********

<p>You should step up and use some of this amazing energy to take action -- the world needs what you've got! It's a really good day for some parties, startups and other fun things that just need some initiative.</p>

推荐答案



试试这个。

Hi,
try this.
string value = "<p>You should step up and use some of this amazing energy to take action -- the 
                world needs what you've got! It's a really good day for some parties, startups and 
                other fun things that just need some initiative.</p><p>More horoscopes! Check your 
                , , , , , ...</p><p>Today's Free Sample Reading: </p><p></p>";

string[] spltvalue = System.Text.RegularExpressions.Regex.Split(value,"</p>");
string finalstringvalue = spltvalue[0] + "</p>";



希望它可以帮到你。


hope it helps you.


尝试使用Jquery ..







Try using Jquery ..



<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <script src="jquery-1.10.2.js" type="text/javascript"></script>
    <script type="text/javascript">


(function(){

var contents =
(function () { var contents =


这篇关于如何只获得asp.net c#中的第一个标签内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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