0
删除标签New
,如果下一个标签是<b>
C#的LINQ to XML,删除基于一个标签的标签名
这里是我的xml文件
<tag>
<New>some content</New>
<b> bold </b>
<New> content two </New>
<p> p tag </p>
</tag>
输出是其内容
<tag>
<b> bold </b>
<New> content two </New>
<p> p tag </p>
</tag>
这里是我的代码
XElement rootImg = XElement.Parse(xml string variable);
IEnumerable<XElement> img =
from el in rootImg.Descendants("New").ToList()
select el;
foreach (XElement el in img)
{
//what am i going to do here?
}
对不起,作为noob。但我如何使用你的代码? – codequery18
将它添加到你的foreach – Raskayu