【发布时间】:2012-03-09 12:05:46
【问题描述】:
我有一个 CRM FetchXML 字符串。这有一个链接实体,这意味着 XML 元素以 GUID 为前缀,例如:
<a_6dd7d25cb0be4150bbaec7c0d2f430c7.lastname>Bob</a_6dd7d25cb0be4150bbaec7c0d2f430c7.lastname>
<a_6dd7d25cb0be4150bbaec7c0d2f430c7.firstname>Bob</a_6dd7d25cb0be4150bbaec7c0d2f430c7.firstname>
<a_6dd7d25cb0be4150bbaec7c0d2f430c7.title name="Mr" formattedvalue="1">1</a_6dd7d25cb0be4150bbaec7c0d2f430c7.title>
我想以类似的方式使用它:
List<FetchResult> results =
(from result in xmlDoc.Descendants("result")
select new FetchResult
{
FirstName = result.Element("firstname").Value
}).ToList<FetchResult>();
显然这行不通,所以无论如何我可以做一个Element.Contains("lastname") 或类似的吗?
如果没有,有没有办法我可以事先从我的字符串中解析出来?也许是正则表达式?
谢谢
【问题讨论】: