Searching Xml Element in any namespace using vb.net


If you know the namespaces that is in the xml document you can use XmlNamespaceManager;

  1. Dim xmlDoc As New XmlDocument()
  2. xmlDoc.Load(Path.Combine(mDirectory, name + "\" + name + ".vbproj"))          '"
  3.  
  4. Dim nsmgr As New XmlNamespaceManager(xmlDoc.NameTable)
  5. nsmgr.AddNamespace("msb", "http://schemas.microsoft.com/developer/msbuild/2003")
  6.  
  7. Dim xpath As String = "/msb:Project/msb:PropertyGroup/msb:ProjectGuid"
  8. Dim value As Object = xmlDoc.SelectNodes(xpath, nsmgr)

else you can use the general XPath syntax

//*[local-name() = 'ProjectGuid']

Source

  1. No comments yet.
(will not be published)
Submit Comment

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word

Subscribe to comments feed
  1. No trackbacks yet.

SetPageWidth