开发者

Find xml element and hyperlink C#

This is what i have in my code

[code]

 string m = MesId;
        StringBuilder builder = new StringBuilder();
        while ("" != m)
        {

            int splitIndex = m.IndexOf('>');
            if (-1 == splitIndex)
            {
                builder.Append(m);
   开发者_StackOverflow社区             break;
            }
            builder.AppendLine(m.Substring(0, splitIndex + 1));
            if (splitIndex == m.Length) { break; }
            m = m.Substring(splitIndex + 1);

        }
        m = builder.ToString();

[/code]

string m = MesId; am getting this value from my table (xml column). used the above function to append new line after ">" and load it in to custom message box.

Now i have a real problem i have to hyperlink the element value <identifier>1268020250775</Identifier>, i know you can use xpath query to fint the element but already am using as a string.

is this anyway i can hyperlink this value in my custom message box ?

Hyper link the <Identifier> element value


Hey Usher this is not tested but try this.

string text = "<identifier>1268020250775</Identifier>";
Regex r1 = new Regex(@"<identifier>(.*?)</Identifier>", RegexOptions.IgnoreCase);
Match match = r1.Match(text);
if (match.Success)
{
   string v = match.Groups[1].Value;
   string link = "<a href=\""+ v +"\">"+ v +"</a>";
   Response.Write(link);
}

Good Luck

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜