开发者

Extract Values between Open/Close Tags

I have many records from a database that have a field with the following appended:

...blah blah. <edited><editID>variable-text-here</editID><editDate>variable-date-here</editDate></edited>

In my C# code I want to get the variable-text and variable-date out of each, to use w开发者_高级运维ithin my program.

What would be the best/most efficient way of doing this?


I would use a regular expression, something like:

Match result = System.Text.RegularExpressions.Regex.Match(inputString,"<editID>.*</editID>");
Match result = System.Text.RegularExpressions.Regex.Match(inputString,"<editDate>.*</editDate>");

Hope it helps!


<editID>[\s\S]*?</editID>

Or deal it as xml.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜