【发布时间】:2013-04-04 11:52:56
【问题描述】:
我想拥有一个风格如下的 XElement:
<g style="fill-opacity:0.7">
所以我这样做了:
XElement root = new XElement("g");
root.SetAttributeValue("style",
from attributes in Child.Attributes
where char.IsUpper(attributes.Key[0]) & !attributes.Value.ToString().StartsWith(transformNS)
select new XAttribute("style", attributes.Key + ":" + attributes.Value));
但我拥有的是
<g style="System.Linq.Enumerable+WhereSelectEnumerableIterator`2[System.Collections.Generic.KeyValuePair`2[System.String,System.Object],System.Xml.Linq.XAttribute]">
有人可以帮助我吗?
最好的问候
【问题讨论】:
-
您是否尝试选择单个子属性?
-
可能不止一个
-
那么你想如何组合它们呢?您的代码不包含任何执行此操作的内容。
-
linq 会将所有属性放在样式中