OPC Studio User's Guide and Reference
BrowseBranches(IEasyDAClient,String,String,String,String,String) Method
Example 



OpcLabs.EasyOpcClassicCore Assembly > OpcLabs.EasyOpc.DataAccess Namespace > IEasyDAClientExtension Class > BrowseBranches Method : BrowseBranches(IEasyDAClient,String,String,String,String,String) Method
The client object that will perform the operation.
Name of the machine (empty string for local computer).
Contains ProgID of the OPC server to browse.
ID of the parent branch to be browsed (empty string for root)
A wildcard string to filter the returned element names (empty string for no filtering)
A server specific filter string (empty string for no filtering)
Browses the specified branch (or root) in OPC server's address space, and returns information about child branches found. Browse for child branches. Specify machine name, server class, element name filter and vendor filter.
Syntax
'Declaration
 
<ExtensionAttribute()>
<ElementsNotNullAttribute()>
<NotNullAttribute()>
Public Overloads Shared Function BrowseBranches( _
   ByVal client As IEasyDAClient, _
   ByVal machineName As String, _
   ByVal serverClass As String, _
   ByVal parentItemId As String, _
   ByVal elementNameFilter As String, _
   ByVal vendorFilter As String _
) As DANodeElementCollection
'Usage
 
Dim client As IEasyDAClient
Dim machineName As String
Dim serverClass As String
Dim parentItemId As String
Dim elementNameFilter As String
Dim vendorFilter As String
Dim value As DANodeElementCollection
 
value = IEasyDAClientExtension.BrowseBranches(client, machineName, serverClass, parentItemId, elementNameFilter, vendorFilter)

Parameters

client
The client object that will perform the operation.
machineName
Name of the machine (empty string for local computer).
serverClass
Contains ProgID of the OPC server to browse.
parentItemId
ID of the parent branch to be browsed (empty string for root)
elementNameFilter
A wildcard string to filter the returned element names (empty string for no filtering)
vendorFilter
A server specific filter string (empty string for no filtering)

Return Value

The method returns a dictionary of OpcLabs.EasyOpc.DataAccess.AddressSpace.DANodeElement values, each containing information about a particular branch found. The keys of the dictionary are the names of the branches.
Exceptions
ExceptionDescription

A null reference (Nothing in Visual Basic) is passed to a method that does not accept it as a valid argument.

This is a usage error, i.e. it will never occur (the exception will not be thrown) in a correctly written program. Your code should not catch this exception.

The OPC "Classic" (or OPC XML-DA) operation has failed. This operation exception in uniformly used to allow common handling of various kinds of errors. The System.Exception.InnerException always contains information about the actual error cause.

This is an operation error that depends on factors external to your program, and thus cannot be always avoided. Your code must handle it appropriately.

Example

.NET

COM

.NET

// This example shows how to obtain all branches at the root of the address space. For each branch, it displays whether 
// it may have child nodes.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

using System;
using OpcLabs.EasyOpc.DataAccess;
using OpcLabs.EasyOpc.DataAccess.AddressSpace;
using OpcLabs.EasyOpc.OperationModel;

namespace DocExamples.DataAccess._EasyDAClient
{
    class BrowseBranches
    {
        public static void Main1()
        {
            // Instantiate the client object.
            var client = new EasyDAClient();
            DANodeElementCollection branchElements;
            try
            {
                branchElements = client.BrowseBranches("", "OPCLabs.KitServer.2", "");
            }
            catch (OpcException opcException)
            {
                Console.WriteLine("*** Failure: {0}", opcException.GetBaseException().Message);
                return;
            }

            foreach (DANodeElement branchElement in branchElements)
                Console.WriteLine($"BranchElements(\"{branchElement.Name}\").HasChildren: {branchElement.HasChildren}");
        }


        // Example output:
        //
        //BranchElements("$ServerControl").HasChildren: True
        //BranchElements("Boilers").HasChildren: True
        //BranchElements("Simulation").HasChildren: True
        //BranchElements("SimulateEvents").HasChildren: True
        //BranchElements("Trends").HasChildren: True
        //BranchElements("Demo").HasChildren: True
        //BranchElements("Greenhouse").HasChildren: True
    }
}
# This example shows how to obtain all branches at the root of the address space. For each branch, it displays whether
# it may have child nodes.
#
# Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
# OPC client and subscriber examples in Python on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-Python .
# The QuickOPC package is needed. Install it using "pip install opclabs_quickopc".
import opclabs_quickopc

# Import .NET namespaces.
from OpcLabs.EasyOpc.DataAccess import *
from OpcLabs.EasyOpc.OperationModel import *


# Instantiate the client object.
client = EasyDAClient()

# Perform the operation.
try:
    nodeElements = IEasyDAClientExtension.BrowseBranches(client, '', 'OPCLabs.KitServer.2', '')
except OpcException as opcException:
    print('*** Failure: ' + opcException.GetBaseException().Message)
    exit()

# Display results.
for nodeElement in nodeElements:
    print('NodeElements["', nodeElement.Name, '"].HasChildren: ', nodeElement.HasChildren, sep='')
' This example shows how to obtain all branches at the root of the address space. For each branch, it displays whether 
' it may have child nodes.
'
' Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

Imports OpcLabs.EasyOpc.DataAccess
Imports OpcLabs.EasyOpc.DataAccess.AddressSpace
Imports OpcLabs.EasyOpc.OperationModel

Namespace DataAccess._EasyDAClient
    Partial Friend Class BrowseBranches
        Shared Sub Main1()
            Dim client = New EasyDAClient()

            Dim branchElements As DANodeElementCollection
            Try
                branchElements = client.BrowseBranches("", "OPCLabs.KitServer.2", "")
            Catch opcException As OpcException
                Console.WriteLine("*** Failure: {0}", opcException.GetBaseException().Message)
                Exit Sub
            End Try

            For Each branchElement In branchElements
                Console.WriteLine($"BranchElements(""{branchElement.Name}"").HasChildren: {branchElement.HasChildren}")
            Next branchElement

        End Sub

        ' Example output
        '
        'BranchElements("$ServerControl").HasChildren: True
        'BranchElements("Boilers").HasChildren: True
        'BranchElements("Simulation").HasChildren: True
        'BranchElements("SimulateEvents").HasChildren: True
        'BranchElements("Trends").HasChildren: True
        'BranchElements("Demo").HasChildren: True
        'BranchElements("Greenhouse").HasChildren: True

    End Class
End Namespace
Rem This example shows how to obtain all branches at the root of the address space. For each branch, it displays whether 
Rem it may have child nodes.
Rem
Rem Find all latest examples here : https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

Option Explicit

Dim Client: Set Client = CreateObject("OpcLabs.EasyOpc.DataAccess.EasyDAClient")
On Error Resume Next
Dim BranchElements: Set BranchElements = Client.BrowseBranches("", "OPCLabs.KitServer.2", "")
If Err.Number <> 0 Then
    WScript.Echo "*** Failure: " & Err.Source & ": " & Err.Description
    WScript.Quit
End If
On Error Goto 0

Dim BranchElement: For Each BranchElement In BranchElements
    WScript.Echo "BranchElements(""" & BranchElement.Name & """).HasChildren: " & BranchElement.HasChildren
Next
// This example shows how to obtain all branches at the root of the address space. For each branch, it displays whether 
// it may have child nodes.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

using System;
using OpcLabs.EasyOpc.DataAccess;
using OpcLabs.EasyOpc.DataAccess.AddressSpace;
using OpcLabs.EasyOpc.OperationModel;

namespace DocExamples.DataAccess.Xml
{
    class BrowseBranches
    {
        public static void Main1Xml()
        {
            // Instantiate the client object.
            var client = new EasyDAClient();
            DANodeElementCollection branchElements;
            try
            {
                branchElements = client.BrowseBranches("http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx");
            }
            catch (OpcException opcException)
            {
                Console.WriteLine("*** Failure: {0}", opcException.GetBaseException().Message);
                return;
            }

            foreach (DANodeElement branchElement in branchElements)
                Console.WriteLine($"BranchElements(\"{branchElement.Name}\").HasChildren: {branchElement.HasChildren}");
        }


        // Example output:
        //
        //BranchElements("Static").HasChildren: True
        //BranchElements("Dynamic").HasChildren: True
    }
}
# This example shows how to obtain all branches at the root of the address space. For each branch, it displays whether 
# it may have child nodes.
#
# Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
# OPC client and subscriber examples in Python on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-Python .
# The QuickOPC package is needed. Install it using "pip install opclabs_quickopc".
import opclabs_quickopc

# Import .NET namespaces.
from OpcLabs.EasyOpc import *
from OpcLabs.EasyOpc.DataAccess import *
from OpcLabs.EasyOpc.DataAccess.AddressSpace import *
from OpcLabs.EasyOpc.OperationModel import *

# Instantiate the client object.
client = EasyDAClient()

try:
    branchElements = IEasyDAClientExtension.BrowseBranches(client, ServerDescriptor('http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx'))
except OpcException as opcException:
    print('*** Failure: ' + opcException.GetBaseException().Message, sep='')
    exit()

for branchElement in branchElements:
    print('BranchElements("', branchElement.Name, '").HasChildren: ', branchElement.HasChildren, sep='')

# Example output:
#
#BranchElements("Static").HasChildren: True
#BranchElements("Dynamic").HasChildren: True
' This example shows how to obtain all branches at the root of the address space. For each branch, it displays whether 
' it may have child nodes.
'
' Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

Imports OpcLabs.EasyOpc.DataAccess
Imports OpcLabs.EasyOpc.DataAccess.AddressSpace
Imports OpcLabs.EasyOpc.OperationModel

Namespace DataAccess.Xml
    Partial Friend Class BrowseBranches
        Shared Sub Main1Xml()
            Dim client = New EasyDAClient()

            Dim branchElements As DANodeElementCollection
            Try
                branchElements = client.BrowseBranches("http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx")
            Catch opcException As OpcException
                Console.WriteLine("*** Failure: {0}", opcException.GetBaseException().Message)
                Exit Sub
            End Try

            For Each branchElement In branchElements
                Console.WriteLine($"BranchElements(""{branchElement.Name}"").HasChildren: {branchElement.HasChildren}")
            Next branchElement

        End Sub

        ' Example output
        '
        'BranchElements("Static").HasChildren: True
        'BranchElements("Dynamic").HasChildren: True

    End Class
End Namespace
Requirements

Target Platforms: .NET Framework: Windows 10 (selected versions), Windows 11 (selected versions), Windows Server 2016, Windows Server 2022; .NET: Linux, macOS, Microsoft Windows

See Also