我基本上想知道如何在另一個XmlDocument中插入XmlDocument。Xml中的Xml
第一個XmlDocument將具有基本的頁眉和頁腳標籤。 第二個XmlDocument將是必須插入到第一個XmlDocument中的主體/數據標記。
string tableData = null;
using(StringWriter sw = new StringWriter())
{
rightsTable.WriteXml(sw);
tableData = sw.ToString();
}
XmlDocument xmlTable = new XmlDocument();
xmlTable.LoadXml(tableData);
StringBuilder build = new StringBuilder();
using (XmlWriter writer = XmlWriter.Create(build, new XmlWriterSettings { OmitXmlDeclaration = true }))
{
writer.WriteStartElement("dataheader");
//need to insert the xmlTable here somehow
writer.WriteEndElement();
}
有沒有更容易的解決方案呢?
那麼把它包括爲CDATA呢? – jtheman
在外部XML節點內使用CDATA節,您將放置內部XML文檔。 –