实际上我有一个带有子节点的xml文件,它工作正常。我想插入一个新的子节点,如Xml name:product.xml
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Table>
<product>
<name>1</name>
<name1>2</name1>
<name2>3</name2>
<name3>4</name3>
<name4>5</name4>
</product>
<!-- I want to insert <product> node with its parameter here -->
</Table>
我尝试了下面的代码并获得了null引用异常,请参考下面的内容并指导我,
Dim xmlDoc As XmlDocument = New XmlDocument()
xmlDoc.Load("product.xml")
DimcourseName = "1"
With xmlDoc.SelectSingleNode("/Table/product[pid = '" & courseName & "']/Table").CreateNavigator().AppendChild()
.WriteStartElement("product")
.Close()
End With