我加入的元素現有的XML文檔用下面的代碼:VB.NET的元素與LINQ添加到XML文檔的XML
Dim theXMLSource As String = Server.MapPath("~/Demo/") & "LabDemo.xml"
Dim nodeElement As XElement
Dim attrAndValue As XElement = _
<LabService>
<ServiceType>
<%= txtServiceType.Text.Trim %>
</ServiceType>
<Level>
<%= txtLevel.Text.Trim %>
</Level>
</LabService>
nodeElement.Add(New XElement(attrAndValue))
nodeElement.Save(theXMLSource)
它使錯誤是這樣的:
System.NullReferenceException: Object reference not set to an instance of an object.
Object reference not set to an instance of an object.
Error line: nodeElement.Add(New XElement(attrAndValue))
我調試它,但我還沒有得到錯誤。你能證明問題是什麼嗎?謝謝
是的,謝謝。 – 2010-03-15 13:58:00