熟悉在NET下操作XML的朋友请进
我将下面代码放到我的CS类,我加了命名空间:using System.Xml;但CreateNode、root都显示有波浪线提示有问题,不知为什么啊,那位高手帮我看看。谢谢
public void AddTableHaderFirstRowSingleCell(string colname, string paramvalue)
{
XmlNode node = null;
XmlNodeList refCd = root.SelectNodes("//default:Report//default:Body//default:ReportItems//default:Table//default:Header//default:TableRows//default:TableRow//default:TableCells", xnm);
XmlElement docFrag = doc.CreateElement("TableCell", "http://schemas.microsoft.com/sqlserver/reporting/2005/01/reportdefinition");
node = CreateNode("ReportItems");
XmlElement textbox = doc.CreateElement("Textbox", "http://schemas.microsoft.com/sqlserver/reporting/2005/01/reportdefinition");
textbox.SetAttribute("Name", colname);
node.AppendChild(textbox);
XmlNode zindex = CreateNode("ZIndex", "12");
textbox.AppendChild(zindex);
XmlNode style = CreateNode("Style");
XmlNode borderstyle = CreateNode("BorderStyle");
style.AppendChild(borderstyle);
XmlNode defaul = CreateNode("Default", "Solid");
borderstyle.AppendChild(defaul);
XmlNode textalign = CreateNode("TextAlign", "Center");
style.AppendChild(textalign);
XmlNode PaddingLeft = CreateNode("PaddingLeft", "2pt");
style.AppendChild(PaddingLeft);
XmlNode PaddingBottom = CreateNode("PaddingBottom", "2pt");
style.AppendChild(PaddingBottom);
XmlNode FontFamily = CreateNode("FontFamily", "宋体");
style.AppendChild(FontFamily);
XmlNode FontWeight = CreateNode("FontWeight", "700");
style.AppendChild(FontWeight);
XmlNode VerticalAlign = CreateNode("VerticalAlign", "Bottom");
style.AppendChild(VerticalAlign);
XmlNode PaddingTop = CreateNode("PaddingTop", "2pt");
style.AppendChild(PaddingTop);
XmlNode PaddingRight = CreateNode("PaddingRight", "2pt");
style.AppendChild(PaddingRight);
textbox.AppendChild(style);
XmlNode cangrow = CreateNode("CanGrow", "true");
textbox.AppendChild(cangrow);
XmlNode value = CreateNode("Value", paramvalue);
textbox.AppendChild(value);
docFrag.AppendChild(node);
refCd[0].InsertAfter(docFrag, refCd[0].LastChild);
doc.Save(filename);
}
------解决方案--------------------
你的root对象是从哪里来的都不知道,CreateNode方法也一样没有``
是从哪里复制的代码吧``?