我已读到以下代码,然后读到所有<代码>img和a
链接。 注:C# 2.0。
string xml = "<xhtml>" + inputXhtml + "</xhtml>";
XmlDocument node = new XmlDocument();
node.LoadXml(xml);
foreach (XmlElement element in TemplateUtilities.SelectNodes(node, "//html:img[@xlink:href]|//html:a[@xlink:href]"))
{
bool flag = element.LocalName == "img";
lStrCompLinkText = "";
XmlAttributeCollection attributes = element.Attributes;
XmlAttribute namedItem = (XmlAttribute)attributes.GetNamedItem("href", "http://www.w3.org/1999/xlink");
string str2 = namedItem.Value;
Component currentObject = engine.GetObject(str2) as Component;
if (flag)
{
element.SetAttribute("src", str2);
}
else
{
foreach (XmlNode xnode in element.ChildNodes)
{
lStrCompLinkText = lStrCompLinkText + xnode.OuterXml;
}
string attr = ComponentBase.ComponentHelper.ComponentLinkAttributes(element, engine);
string compLink = ComponentBase.ComponentHelper.DisplayPublishedComponentLink(currentObject, lStrCompLinkText, attr, engine, package, pageObject);
attributes.RemoveNamedItem("href", "http://www.tridion.com/ContentManager/5.0");
//Here I want to replace whole element with the compLink
}
attributes.RemoveNamedItem("href", "http://www.w3.org/1999/xlink");
attributes.RemoveNamedItem("type", "http://www.w3.org/1999/xlink");
attributes.RemoveNamedItem("title", "http://www.w3.org/1999/xlink");
}
现在,我想用新的价值“红外线”来补充我的内容,并补充对超文本投入的投入。
请建议