VB.NET: Searching Through The XML Nodes On Conditional Attribute Value

Searching in the XML file to get a particular node with an attribute of the given value is sometimes quite confusing.

Here is a simple generic function to solve that problem.

It takes the following parameters:

  • xelRootNode: in most cases, I pass the documentElement, but if you want to search inside a particular node, pass that.

  • strAttribName: The name of the attribute to be checked.

  • strAttribValue: The attribute value to be matched.

  • xelResultNode: Byref, to return the node found

  • strSearchNodesBaseName: Optional, if the search is to be done in nodes of any particular name.

Hope this will be useful for generic purposes.

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish