我正在尝试将所有“CSS”元素“value”的值设置为“”,这是代码:
XDocument doc = XDocument.Load(fi.FullName);
XNamespace rep = "http://developer.cognos.com/schemas/report/8.0/";
List<XElement> cssElements =
(from e in doc.Root.DescendantsAndSelf(rep + "CSS")
where
(
(e.Attribute("value") != null)
)
select e).ToList();
//modify Attribute in elements
foreach (XElement xe in cssElements)
{
xe.Attribute("value").Value = "";
}
但是,我不想修改这个 CSS,它的祖先是“crosstab”和“style”(下面的 xml):
<crosstab name="Crosstab1" refQuery="Query1">
<crosstabSuppress type="rows"/>
<style>
<CSS value="border-collapse:collapse;font-family:'Times New Roman'"/>
我怎样才能做到这一点?谢谢!