0
我在下面的函數中收到此錯誤。要插入的節點來自不同的文檔上下文
Public Function GetXmlEnvironment(ByVal xmlTree As XmlNode, ByVal objUser As XTUser, ByVal objModule As XTModuleInfo, ByVal objProject As XTProject, ByVal objPage As IXTPage) As XmlNode
Dim objXml As XmlDocument = New XmlDocument()
Dim xmlEnvironment As XmlElement
xmlEnvironment = objXml.CreateElement("Environment")
If (xmlTree.HasChildNodes()) Then
xmlTree.FirstChild.AppendChild(xmlEnvironment) ' Error occurs here
End If
' ...
End Function
我是否需要將XmlElement轉換爲XmlNode?
使用xmlTree.FirstChild的OwnerDocument創建一個新元素,而不是全新的XmlDocument。 – Will
@Parfait,標題是錯誤。 –
我打算在添加節點之前先說'導入'節點... – Codexer