QuickOPC User's Guide and Reference
Parse Method (UABrowsePathParser)
Example 



OpcLabs.EasyOpcUA Assembly > OpcLabs.EasyOpc.UA.Navigation.Parsing Namespace > UABrowsePathParser Class : Parse Method
The string containing the absolute browse path to be parsed.
Parses a string containing an absolute browse path, and returns a corresponding browse path object.
Syntax
'Declaration
 
<NotNullAttribute()>
<PureAttribute()>
Public Function Parse( _
   ByVal value As String _
) As UABrowsePath
'Usage
 
Dim instance As UABrowsePathParser
Dim value As String
Dim value As UABrowsePath
 
value = instance.Parse(value)
[NotNull()]
[Pure()]
public UABrowsePath Parse( 
   string value
)
[NotNull()]
[Pure()]
public:
UABrowsePath^ Parse( 
   String^ value
) 

Parameters

value
The string containing the absolute browse path to be parsed.

Return Value

Returns the browse path object parsed from the input value.
Exceptions
ExceptionDescription
Thrown when the OPC UA browse path cannot be parsed.
Remarks
The input browse path must be absolute.
Example

.NET

COM

// Parses an absolute  OPC-UA browse path and displays its starting node and elements.

using System;
using OpcLabs.EasyOpc.UA.Navigation;
using OpcLabs.EasyOpc.UA.Navigation.Parsing;

namespace UADocExamples._UABrowsePathParser
{
    class Parse
    {
        public static void Main1()
        {
            var browsePathParser = new UABrowsePathParser();
            UABrowsePath browsePath;
            try
            {
                browsePath = browsePathParser.Parse("[ObjectsFolder]/Data/Static/UserScalar");
            }
            catch (UABrowsePathFormatException browsePathFormatException)
            {
                Console.WriteLine("*** Failure: {0}", browsePathFormatException.GetBaseException().Message);
                return;
            }

            // Display results
            Console.WriteLine("StartingNodeId: {0}", browsePath.StartingNodeId);

            foreach (UABrowsePathElement browsePathElement in browsePath.Elements)
                Console.WriteLine(browsePathElement);

            // Example output:
            // StartingNodeId: ObjectsFolder
            // /Data
            // /Static
            // /UserScalar
        }
    }
}
# Parses an absolute  OPC-UA browse path and displays its starting node and elements.

# The QuickOPC package is needed. Install it using "pip install opclabs_quickopc".
import opclabs_quickopc

# Import .NET namespaces.
from OpcLabs.EasyOpc.UA import *
from OpcLabs.EasyOpc.UA.Navigation import *
from OpcLabs.EasyOpc.UA.Navigation.Parsing import *


browsePathParser = UABrowsePathParser()
try:
    browsePath = browsePathParser.Parse('[ObjectsFolder]/Data/Static/UserScalar')
except UABrowsePathFormatException as browsePathFormatException:
    print('*** Failure: ' + browsePathFormatException.GetBaseException().Message)
    exit()

# Display results.
print('StartingNodeId: ', browsePath.StartingNodeId, sep='')

print()
for browsePathElement in browsePath.Elements:
    print(browsePathElement)

print()
print('Finished.')
' Parses an absolute  OPC-UA browse path and displays its starting node and elements.

Imports OpcLabs.EasyOpc.UA.Navigation
Imports OpcLabs.EasyOpc.UA.Navigation.Parsing

Namespace _UABrowsePathParser
    Friend Class Parse
        Public Shared Sub Main1()
            Dim browsePathParser = New UABrowsePathParser()
            Dim browsePath As UABrowsePath
            Try
                browsePath = browsePathParser.Parse("[ObjectsFolder]/Data/Static/UserScalar")
            Catch browsePathFormatException As UABrowsePathFormatException
                Console.WriteLine("*** Failure: {0}", browsePathFormatException.GetBaseException.Message)
                Exit Sub
            End Try

            ' Display results
            Console.WriteLine("StartingNodeId: {0}", browsePath.StartingNodeId)

            For Each browsePathElement As UABrowsePathElement In browsePath.Elements
                Console.WriteLine(browsePathElement)
            Next browsePathElement

            ' Example output:
            ' StartingNodeId: ObjectsFolder
            ' /Data
            ' /Static
            ' /UserScalar
        End Sub
    End Class
End Namespace
// Parses an absolute  OPC-UA browse path and displays its starting node and elements.

class procedure Parse.Main;
var
  BrowsePath: _UABrowsePath;
  BrowsePathElement: _UABrowsePathElement;
  BrowsePathParser: OpcLabs_EasyOpcUA_TLB._UABrowsePathParser;
  Count: Cardinal;
  Element: OleVariant;
  ElementEnumerator: IEnumVariant;
begin
  BrowsePathParser := CoUABrowsePathParser.Create;

  try
    BrowsePath := BrowsePathParser.Parse('[ObjectsFolder]/Data/Static/UserScalar');
  except
    on E: EOleException do
    begin
      WriteLn(Format('*** Failure: %s', [E.GetBaseException.Message]));
      Exit;
    end;
  end;

  // Display results
  WriteLn('StartingNodeId: ', BrowsePath.StartingNodeId.ToString);

  WriteLn('Elements:');
  ElementEnumerator := BrowsePath.Elements.GetEnumerator;
  while (ElementEnumerator.Next(1, Element, Count) = S_OK) do
  begin
    BrowsePathElement := IUnknown(Element) as _UABrowsePathElement;
    WriteLn(BrowsePathElement.ToString);
  end;

  // Example output:
  // StartingNodeId: ObjectsFolder
  // Elements:
  // /Data
  // /Static
  // /UserScalar

end;
// Parses an absolute  OPC-UA browse path and displays its starting node and elements.


$BrowsePathParser = new COM("OpcLabs.EasyOpc.UA.Navigation.Parsing.UABrowsePathParser");

try
{
    $BrowsePath = $BrowsePathParser->Parse("[ObjectsFolder]/Data/Static/UserScalar");
}
catch (com_exception $e)
{
    printf("*** Failure: %s\n", $e->getMessage());
    exit();
}

// Display results
printf("StartingNodeId: %s\n", $BrowsePath->StartingNodeId);

printf("Elements:\n");

for ($i = 0; $i < $BrowsePath->Elements->Count; $i++)
{
    printf("%s\n", $BrowsePath->Elements[$i]);
}

// Example output:
// StartingNodeId: ObjectsFolder
// Elements:
// /Data
// /Static
// /UserScalar
Rem Parses an absolute  OPC-UA browse path and displays its starting node and elements.

Private Sub Parse_Main_Command_Click()
    OutputText = ""
    
    Dim BrowsePathParser As New UABrowsePathParser

    On Error Resume Next
    Dim browsePath As UABrowsePath
    Set browsePath = BrowsePathParser.Parse("[ObjectsFolder]/Data/Static/UserScalar")
    If Err.Number <> 0 Then
        OutputText = OutputText & "*** Failure: " & Err.Source & ": " & Err.Description & vbCrLf
        Exit Sub
    End If
    On Error GoTo 0
    
    ' Display results
    OutputText = OutputText & "StartingNodeId: " & browsePath.StartingNodeId & vbCrLf
    
    OutputText = OutputText & "Elements:" & vbCrLf
    Dim BrowsePathElement: For Each BrowsePathElement In browsePath.Elements
        OutputText = OutputText & BrowsePathElement & vbCrLf
    Next

    ' Example output:
    'StartingNodeId: ObjectsFolder
    'Elements:
    '/Data
    '/Static
    '/UserScalar
End Sub
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