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.
精彩评论