I have a DOM tree (xmlCOA).
It is associated with a TreeView (TreeView1).
I would like to add a new node to the DOM tree.
After I construct the new node, I locate a particular node for adding the new node as its child.
I use "fullPath" to construct the xpath to locate the targeted node.
But, I don't understand something: the fullPath return: #document/.......
Should I trim the "#document" away?
No matter I cut it or not, it causes error: wrong xpath expression.
Why?



visual basic code:--------------------------------------------------------------------------------
VB Code:
  1. Private Sub btnCreate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCreate.Click
  2.         'construct the new node
  3.         Dim newNode As xmlFile.XmlNode = _
  4.                 xmlCOA.CreateNode(Xml.XmlNodeType.Element, "",  txtElementName.Text, "")
  5.         newNode.InnerText() = txtItemName.Text
  6.  
  7.         'construct the xpath
  8.         Dim txt As String = TreeView1.SelectedNode.Text
  9.         Dim fullPath As String = TreeView1.SelectedNode.FullPath 'return value is: #document/.......
  10.         fullPath = fullPath.substring(9) 'cut "#document"
  11.  
  12.         'this is valid, but it cannot locate the exact node
  13.         'Dim xn As xmlFile.XmlNode = xmlCOA.SelectSingleNode("//" + txt)
  14.  
  15.         'error: xpath is not valid
  16.         Dim xn As xmlFile.XmlNode = xmlCOA.SelectSingleNode(fullpath)
  17.  
  18.         xn.AppendChild(newNode)
  19.     End Sub